commander-file
v0.0.5
Published
Receive file/uri and stdin at commander
Downloads
55
Readme
Commander file
Receive file/uri and stdin at commander.js
- Fetch data after parse via first argument or
--stdin
. - First argument always return the file.
Usage
$ npm install commander-file --save
./program.js
#!/usr/bin/env node
var program = require('commander-file');
program
.version('0.0.0')
.usage('<file/url> dostaff [options...]')
.parse(process.argv).then(function(data){
console.log(data);
console.log(program.args[0]);
console.log(program.args[1]);
});
$ node program.js --help
#
# Usage: program <file/url> dostaff [options...]
#
# Options:
#
# -h, --help output usage information
# -S, --stdin use the stdin
# -V, --version output the version number
# stdin
$ echo -n 'foo' | node program.js --stdin dostaff
# foo
# null
# dostaff
$ node program.js bar.txt dostaff
# bar
# bar.txt
# dostaff
# uri
$ node program.js http://example.com/baz.txt dostaff
# baz
# http://example.com/baz.txt
# dostaff