Package Exports
- make-cli
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 (make-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
make-cli
Build command line tools declaratively with a configuration object and a single function call. Based on Commander.js
Installation
# via NPM
npm install --save make-cli
# via Yarn
yarn add make-cli
Usage
First the CLI has to be implemented:
#!/usr/bin/env node
const makeCli = require('make-cli')
makeCli({
version: '0.1.0',
name: 'my-cli',
usage: 'Usage description here',
arguments: '<remote> [extra]',
options: [
{
name: '-y, --yes',
description: 'Skip questions',
},
{
name: '--value <value>',
description: 'Specifies the value',
},
],
action: (remote, extra, { value }) => { /* Do stuff with the parameters */ },
})
// It is also possible to define sub-commands
makeCli({
commands: [
{
name: 'push',
description: 'Pushes to the repo',
arguments: '<remote>',
options: [
{
name: '-y, --yes',
},
],
action: (remote, { yes }) => { /* push the stuff */ },
},
{
name: 'pull',
// ...
},
],
})
Then it can be called like so:
$ my-cli push origin --yes
$ my-cli pull origin
$ my-cli --help
$ my-cli --version
For more information see the Commander.js website.
License
MIT © Sebastian Landwehr