commander-file

0.0.5 • Public • Published

Commander file NPM version Build Status Coverage Status

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 

License

MIT

Package Sidebar

Install

npm i commander-file

Weekly Downloads

13

Version

0.0.5

License

MIT

Last publish

Collaborators

  • 59naga