Skip to content

[ts-command-line] Support stdin/piping #5135

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

Open
douglasg14b opened this issue Feb 25, 2025 · 4 comments
Open

[ts-command-line] Support stdin/piping #5135

douglasg14b opened this issue Feb 25, 2025 · 4 comments

Comments

@douglasg14b
Copy link

Summary

Command line should support stdin to support piping from other CLIs

Repro steps

Crate a CLI, and try and pipe data into it like eco something | tsx ./myCli.ts myCommand

Details

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
Package name: @rushstack/ts-command-line
Package version? 4.23.2
Operating system? Linux
Would you consider contributing a PR? Yes
Node.js version (node -v)? v22
@iclanton
Copy link
Member

Seems like a useful feature. How would you expect that to look from an API perspective?

@iclanton iclanton moved this from Needs triage to General Discussions in Bug Triage Feb 26, 2025
@dmichon-msft
Copy link
Contributor

Ultimately the role of ts-command-line is to be an argument parser, so accepting input from stdin isn't really in scope. Individual actions are free to read from stdin as part of their implementation, but that doesn't require any logic on the part of ts-command-line to make happen.

For example, for the UNIX convention, an argument that asks for a filename might be coded to accept - as a valid value, at which point the underlying action implementation that reads that file should interpret - as a directive to read from stdin instead of a particular file on disk, but from the perspective of ts-command-line, its work ended when it handed you the value - from the parameter.

@dmichon-msft
Copy link
Contributor

I assumed you meant as one of the file inputs (as is the standard UNIX convention), did you mean that you want to support piping in the command line arguments?

@douglasg14b
Copy link
Author

No, I think I meant the former. Having a built-in way to nab stdin as a built in would be handy, but I see what you mean.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: General Discussions
Development

No branches or pull requests

3 participants