Skip to content

The programmatic solution for command-line interfaces, inspired by commander.js

License

Notifications You must be signed in to change notification settings

trustedtomato/commandy

Repository files navigation

commandy

Build Status dependencies Status devDependencies Status PRs Welcome npm Downloads

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

About

The programmatic solution for command-line interfaces, inspired by commander.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published