Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jguddas/oargs
CLI framework with a focus on easy subcommand creation.
https://github.com/jguddas/oargs
Last synced: about 1 month ago
JSON representation
CLI framework with a focus on easy subcommand creation.
- Host: GitHub
- URL: https://github.com/jguddas/oargs
- Owner: jguddas
- Created: 2018-03-22T14:22:07.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-10T13:37:21.000Z (over 6 years ago)
- Last Synced: 2024-10-14T09:52:50.854Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
oargs
=======Oargs is a CLI framework with a focus on easy subcommand creation.
Installation
------------```
npm i oargs
```Usage
-----```js
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.
```js
const oargs = require('oargs')
const cli = oargs()
```### cli.command(name, [options], [callback])
Add CLI subcommand.
- name: `string`
- options: `object`
- description: `string`
- alias: `string` `Array`
- filter: `string` `Array` command group, defaults to `default`
- inHelp: `boolean` show in help, defaults to `true`
- aliases: `object` hidden option aliases
- options: `object` options, (not recommended use option command instead)
- callback: `function` command handler
- object: `object`
- command: `object` command object
- mapped: `object` grouped flags
- argv: `object` minimist object### cli.command( ... ).option(name, [options])
Add subcommand option.
- name: `string`
- options: `object`
- description: `string`
- alias: `string` `Array`
- filter: `string` `Array` option group, defaults to command groups
- default: `any` default value
- defaults: `object` group specific defaults
- overide: `any` always override value
- overides: `object` grconst cli = oargs()oups specific overrides
- mapper: `function` modify value using a function
- value: `any` command flag value
- filter: `string` option group### cli.help([options])
Return help string.
- options: `object`
- name: `string` CLI name
- description: `string` CLI description
- version: `string` version
- bin: `string`, `object` binary name, defaults to basename of `argv[1]`
- showPkgInfo: `boolean` show description, name and version, defaults to `true````js
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.