Commander.js
A cheatsheet by @rstacruz|Refreshed 7 months ago.Refresh|View source on Github

Initialize

Initialize

var cli = require('commander');

Options

Options

cli
  .version(require('../package').version)
  .usage('[options] <command>')
  .option('-w, --words <n>', 'generate <n> words')
  .option('-i, --interval <n>', 'interval [1000]', 1000)
  .option('-s, --symbols', 'include symbols')
  .parse(process.argv);

Help

Help

.on('--help', function() {
  console.log('');
})

Commands

Commands

cli.outputHelp();
cli.args == ["hello"];