Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jankaszel/argv-options
opinionated argv options parser
https://github.com/jankaszel/argv-options
args cli nodejs
Last synced: 17 days ago
JSON representation
opinionated argv options parser
- Host: GitHub
- URL: https://github.com/jankaszel/argv-options
- Owner: jankaszel
- License: mit
- Created: 2017-01-21T14:41:24.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-23T13:05:59.000Z (over 7 years ago)
- Last Synced: 2024-10-22T04:14:34.052Z (17 days ago)
- Topics: args, cli, nodejs
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# argv-options
[![npm](https://img.shields.io/npm/v/argv-options.svg)](https://www.npmjs.com/package/argv-options)
[![Travis](https://travis-ci.org/fallafeljan/argv-options.svg)]()`argv-options` subjectively parses your `argv` options, i.e., it makes
assumptions about how your CLI is designed to keep the API simple. It expects your `argv` object to be supplied in the format of `-p foo --param bar`, i.e.,
simple key-value arguments that may be aliased (using `--`).## API
`parseOptions(argv, options)`
This method will return the parsed options in a key-value based object,
including all found options and their respective aliases. The following
arugments are mandatory:* `argv` The arguments array, as space-split array of all parameters. In your
average usage case, passing `process.argv.slice(2)` will do.
* `options` The possible options, as object:```json
{
"p": {
"optional": false,
"alias": "param"
},"a": {
"optional": true,
"alias": "argument"
}
}
```Parameters are required (`optional` is false) by default. Alternatively, for
more convenient use, aliases may be specified by using the key's value:```json
{
"p": "param"
}
```If any non-optional parameters are missing or undocumented parameters occur,
`parseOptions` will throw an error.