cmd-ln

Converts command-line arguments to function arguments - for simple CLI programs.

cmd-ln

Converts command-line arguments to function arguments - for simple CLI programs.

npm install cmd-ln

program:

#! /usr/bin/env node
var cmdLn = require('cmd-ln')
 
cmdLn(function(actionsubject){
  console.log('I am going to do', action, 'with', subject + '.')
})

Running that and get.

$ program make lemonade
I am going to do make with lemonade.
$ program make
Usage: program <action> <subject>
$ program
Usage: program <action> <subject>

You can specify optional parameters using a leading underscore:

var cmdLn = require('./')
 
cmdLn(function(_url){
  var url = _url || 'http://google.com'
  console.log(url)
})