2.1.0 • Published 7 years ago
oargs v2.1.0
oargs
Oargs is a CLI framework with a focus on easy subcommand creation.
Installation
npm i oargsUsage
const oargs = require('orargs')
const cli = oargs()
cli
.command('command', { description: 'example command' }, console.log)
.option('first', { description: 'first option' })
.option('second', { description: 'second option' })
if (!cli.parse()) cli.showHelp(require('./package.json'))Documentation
oargs()
Create CLI.
const oargs = require('oargs')
const cli = oargs()cli.command(name, options, callback)
Add CLI subcommand.
- name:
string - options:
object- description:
string - alias:
stringArray<string> - filter:
stringArray<string>command group, defaults todefault - inHelp:
booleanshow in help, defaults totrue - aliases:
objecthidden option aliases - options:
objectoptions, (not recommended use option command instead)
- description:
- callback:
functioncommand handler- object:
object- command:
objectcommand object - mapped:
objectgrouped flags - argv:
objectminimist object
- command:
- object:
cli.command( ... ).option(name, options)
Add subcommand option.
- name:
string - options:
object- description:
string - alias:
stringArray<string> - filter:
stringArray<string>option group, defaults to command groups - default:
anydefault value - defaults:
objectgroup specific defaults - overide:
anyalways override value - overides:
objectgrconst cli = oargs()oups specific overrides - mapper:
functionmodify value using a function- value:
anycommand flag value - filter:
stringoption group
- value:
- description:
cli.help(options)
Return help string.
- options:
object- name:
stringCLI name - description:
stringCLI description - version:
stringversion - bin:
string,objectbinary name, defaults to basename ofargv[1] - showPkgInfo:
booleanshow description, name and version, defaults totrue
- name:
cli.help(require('./package.json'))cli.showHelp(options)
Print help string.
Same as console.log(cli.help(options)).
cli.parse(argv)
Parse CLI and call callback.
- argv:
object, defaults to minimist object
Returns command callback options or false.