johnnovak / illwill

A curses inspired simple cross-platform console library for Nim
Do What The F*ck You Want To Public License
398 stars 27 forks source link

Add option to use stderr instead of stdout #28

Closed hectormonacci closed 2 years ago

hectormonacci commented 2 years ago

When an illwill app is called directly from a tty, its stdout screenpainting works flawlessly. If you use illwill to design an app whose output needs to be captured in a variable, though, you have to manually redirect the illwill app stdout to stderr using 1>&2, in order not to pollute the stdout output of your app.

Can you add an initialization option so that illwill will use stderr instead of stdout for screenpainting?

johnnovak commented 2 years ago

No, that sounds very hacky. It's supposed to be used for interactive apps that have a UI, and by definition you don't redirect the output of such apps to a file, that's very atypical.

hectormonacci commented 2 years ago

The case use I mentioned is not "output to a file" (I didn't even mention "file").

It is very common practice in Bash TUI scripts, e.g. using dialog and whiptail, to capture "output to a variable". Example:

choice=$(menu "Tell us your preference" "Fish" "Pasta"); echo $choice

johnnovak commented 2 years ago

Okay, I got it now. Well, I don't need this personally, so PRs are welcome :)