commandy
v3.0.0
Published
The programmatic solution for command-line interfaces, inspired by commander.js
Downloads
5
Readme
commandy
If you want to create a command line app which is hard to make with minimist, but don't want the syntactic sugar overdose which commander.js gives, this package is for you.
Demo
const {Program} = require('../');
const checkoutProgram = new Program();
const orderProgram = new Program([
['p', 'pepperoni'],
['c', 'cheese'],
['h', 'ham']
])
const pizzaProgram = new Program({
checkout: checkoutProgram,
order: orderProgram
});
const margaretaCheckout = pizzaProgram.parse(['checkout','margareta']);
console.log(margaretaCheckout.program === checkoutProgram);
// => true
console.log(margaretaCheckout.args)
// => [ 'margareta' ]
const order = pizzaProgram.parse(['order','-ch','hawaii','-c','--pepperoni=little'])
console.log(order.args);
// => [ 'hawaii' ]
console.log(order.options.cheese);
// => [ true, true ]
console.log(order.options.ham);
// => [ true ]
console.log(order.options.pepperoni);
// => [ 'little' ]
Installation
npm install commandy --save