λ
JS
$ clever deploy
$ clever log
$ clever status
$ executable
-a -b
--test=value
argument
$ executable
-a -b
--test=value
argument
$ executable
-ab
--test=value
argument
$ executable
--auto --bytes
--test=value
argument
$ executable
-ab
--test=value
argument
$ executable
-ab
--test value
argument
$ executable
-ab
-t value
argument
$ executable
-ab
-tvalue
argument
$ executable
-a -b
--test=value
argument
$ executable
-a -b
--test=value
-- -argument
minimist
var parse = require('minimist');
var argv = parse(process.argv.slice(2));
node executable.js
-ab --test=value
argument
{ _: ["argument"]
, a: true
, b: true
, test: "value"
}
yargs
var argv = require('yargs').argv;
if (argv.rif - 5 * argv.xup > 7.138) {
console.log('Plunder more riffiwobbles!');
} else {
console.log('Drop the xupptumblers!');
}
var argv = require('yargs')
.usage('Usage: $0 -x [num] -y [num]')
.demand(['x','y'])
.argv;
nomnom
var parser = require("nomnom");
parser.command('browser')
.callback(function(opts) {
runBrowser(opts.url);
})
.help("run browser tests");
var testCli = cli({
name: "my-executable",
description: "Description",
commands: [
command(
"echo",
{ description: "Display the given value",
args: [
argument("value",
{ description: "V" })
],
options: [
flag("reverse",
{ aliases: ["r"],
description: "Reverse the value"})
]
},
echoModule)
]
});
cliparse.parse(testCli);
CommandTree -> ???
./subcommands.js --help
Usage: testCli
Simple CLI written for the sake of the example
Options:
[--help, -?] Display help about this program
[--version, -V] Display the version of this program
Available Commands:
help display help about this program
number perform simple arithmetic calculations
./subcommands.js help number
Usage: testCli number
perform simple arithmetic calculations
Options:
[--help, -?] Display help about this program
[--version, -V] Display the version of this program
Available Commands:
add add two integers
multiply multiply two integers
argument("int",
{ default: 0,
parser: intParser,
description: "Int to add 2 to" })
var colorCompleter = function() {
return autocomplete.words([
'mauve',
'blue',
'yellow',
'purple',
'parabolic'
]);
};