-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support piping #137
Labels
Comments
👍 This is what I did: //...
var stdin = '';
program
.command('some-command [message]')
.action(function(message) {
if(stdin) {
message = stdin;
}
});
if(process.stdin.isTTY) {
program.parse(process.argv);
}
else {
process.stdin.on('readable', function() {
var chunk = this.read();
if (chunk !== null) {
stdin += chunk;
}
});
process.stdin.on('end', function() {
program.parse(process.argv);
});
} |
I did the same thing here. Works like a charm. |
Popular approach from @jrschumacher , thanks This issue has not had any activity in over six months. It isn't likely to get acted on due to this report. Feel free to open a new issue if it comes up again, with new information and renewed interest. Thank you for your contributions. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Say you want to support piping in your script, e.g.:
That’s currently possible using code that looks like this:
It would be neat if commander.js could somehow abstract all this away and make it easier to write scripts that accept piped content.
The text was updated successfully, but these errors were encountered: