-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Piping from echo
to provide standard input
#172
Comments
As a variation of this, a heredoc is also a convenient option to explore: $ my-tool --args <<END
[1, 2, 3]
END
[4, 5, 6] They might be easier to implement because they don't require running arbitrary commands. (Then again, |
A preliminary exploration comparing echo to the heredoc I suggested above indicates that echo is reasonably easy to handle on its own. One aspect possibly worth discussing is the approach to evaluate the pipe; two variations come to mind -- fork out to processes or shim common commands
With 1 being easy and attainable, and 2 providing a compatible extension, I'd like to suggest going route 1 now – it solves a practical issue, is not a 100% solution, but does not raise portability, security or complexity concerns. |
I like option 1. Option 2 solves needs for which there seems to be no demand. Option 1 can be solved with only a little code as in the PR, so if demand for option 2 grows in the future, it can easily be replaced. My goal in the readme is to provide simple examples that can be modified (eg replace the echo portion with other commands). The heredoc option (option 0) is not ideal as users of my CLI are typically doing many pipes through several commands; they are not expected to use heredocs themselves, so it might be confusing or misleading to use heredocs in the readme. |
My use case is slightly different but would benefit from having pipes supported as well: My app uses the IsTerminal trait to check whether we are running an interactive session or not and I would like to test this behavior. I started to write tests for the interactive part with rexpect but would like to test the non-interactive part with trycmd since it seems way easier for me to define tests. Having support for |
I'd like to be able to show examples in my documentation that use standard input. My usual way to document this is something like:
... so that users can copy-paste it and get the same result (and then modify as needed). It would be great to be able to test that these examples work using trycmd.
Moved from #168 (comment)
The text was updated successfully, but these errors were encountered: