Replies: 2 comments
-
We found the following entry in the FAQ which you may find helpful: Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review. This is an automated reply, generated by FAQtory |
Beta Was this translation helpful? Give feedback.
-
So what is it that you think needs further discussion that should here instead of an enhancement issue? As I mentioned, there have already been a few places here where this has been discussed, and workarounds proposed. Is the very fact whether this should be added as a built-in feature contentious, or is it the precise form such a feature should take? |
Beta Was this translation helpful? Give feedback.
-
It is currently undocumented how textual behaves when you pipe into a program
echo test | my_textual_program
. There are a few issues and discussions here on GitHub that will tell you that textual polls STDIN regularly, so if that is not connected to a controlling TTY, textual will crash.Also in these issues and discussions one can find various workarounds, but the best one seems to be what is done in the Textualize/toolong project (https://github.com/Textualize/toolong/blob/main/src/toolong/cli.py#L36), where the app detects that
sys.stdin
is a pipe, reopens the pipelines controlling TTY, and runs itself as a subprocess to which it attaches the reopend TTY as its stdin. Then it reads from its own stdin and writes everything that gets piped in into a tempfile that the subprocess then reads.IMO this should be incorporated into textual proper in the form of a e.g. a helper function to get at least simple apps going that allow data being piped in.
But in the short term this should be at least documented so a search on textual.textualize.io for terms like stdin, pipe, or pipeline can find the info that this is currently only supported via a workaround.
Beta Was this translation helpful? Give feedback.
All reactions