pipe-args
pipe-args adds support for unix piped arguments to your node CLI apps
pipe-args makes your node CLI apps to fully support unix pipelines, completely out of the box. Require the the pipe-args module and all the piped arguments are added to the process stdin transparently. It also integrates well with popular command line interface/parsers like yarg and commander.js.
Installation
$ npm install --save pipe-args
Usage
#!/usr/bin/env node const pipe = ;console;
$ echo test | node index.js $ The piped arg is test
Options
You can define which commands allow the stdin to be copied to process.argv by
passing them in the options
object:
#!/usr/bin/env node const pipe = ;console;
$ echo OK | node command index.js $ The piped arg is OK
$ echo OK | node commandNotPiping index.js $ The piped arg is null // stdin was not parsed into process.argv
Integrations
pipe-args plays along with optstrings parsers such as yarg. The following yargs parser code:
#!/usr/bin/env node const pipe = ;const yargs = const cli = yargs console;
parses linux-style piped arguments as expected:
$ echo piped_arg | yargs-cli.js $
License:
MIT © Gonçalo Pestana