Package Exports
- clap
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (clap) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Clap.js
Argument parser for command-line interfaces. It primary target to large tool sets that provides a lot of subcommands. Support for argument coercion and completion makes task run much easer, even if you doesn't use CLI.
Usage
npm install clap
const cli = require('clap');
const myCommand = cli.command('my-command', '[optional-arg]')
.description('Optional description')
.version('1.2.3')
.option('-b, --bool', 'Bollean option')
.option('--foo <foo>', 'Option with required argument')
.option('--bar [bar]', 'Option with optional argument')
.option('--baz [value]', 'Option with optional argument and normalize function', function(value) {
// calls on init and for any value set
return Number(value);
}, 123) // 123 is default
.action(function(args, literalArgs) {
// args goes before options
// literal args goes after --
// this.values is an object with collected values
});
myCommand.run(); // runs with process.argv.slice(2)
myCommand.run(['--foo', '123', '-b'])
// sub-commands
myCommand
.command('nested')
.option('-q, --quz', 'Some parameter', 'Default value')
// ...
.end()
.command('another-command')
// ...
.command('level3-command')
//...
License
MIT