https://github.com/tiaanduplessis/get-them-args
Parse argument options
https://github.com/tiaanduplessis/get-them-args
arguments parse
Last synced: 11 months ago
JSON representation
Parse argument options
- Host: GitHub
- URL: https://github.com/tiaanduplessis/get-them-args
- Owner: tiaanduplessis
- License: mit
- Created: 2016-12-17T12:18:17.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-04-22T10:37:55.000Z (about 6 years ago)
- Last Synced: 2025-06-15T15:51:50.081Z (about 1 year ago)
- Topics: arguments, parse
- Language: JavaScript
- Homepage:
- Size: 183 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# get-them-args
[](https://npmjs.org/package/get-them-args)
[](https://npmjs.org/package/get-them-args)
[](https://github.com/RichardLitt/standard-readme)
[](https://npmjs.org/package/get-them-args)
[](http://makeapullrequest.com) [](https://greenkeeper.io/)
> Parse argument options
## Table of Contents
- [About](#about)
- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#License)
## About
Simple CLI argument parser hacked from [minimist](https://github.com/substack/minimist) that adds support for objects and additional initialization options.
## Install
```sh
$ npm install --save get-them-args
# Or
$ yarn add get-them-args
```
## Usage
To use, provide arguments as argument:
```js
const parse = require('get-them-args')
const options = {} // Options to be passed. CURRENTLY NONE AVAILABLE
// $ node ./example.js --dir . --command foo
console.log(parse(process.argv.slice(2) ))
// { unknown: [], dir: '.', command: 'foo' }
console.log(parse(process.argv))
// { unknown: [], dir: '.', command: 'foo' }
console.log(parse())
// { unknown: [], dir: '.', command: 'foo' }
```
For example, if the arguments provided are `--hello world --parse=all --no-drugs --make-friends -n 4 -t 5`, the function will return:
```js
{ unknown: [],
hello: 'world',
parse: 'all',
drugs: false,
'make-friends': true,
n: 4,
t: 5
}
```
There is also support for parsing objects:
```sh
$ node example.js --headers={"Foo": "5", "bar": "6"}
# { unknown: [], headers: { Foo: 5, bar: 6 } }
```
All unparsed arguments will end up in the `unknown` array. The following types of arguments are supported:
```sh
--key=value
--key value
--key # true
--no-key # false
-key=value
-key value
```
## Contribute
1. Fork it and create your feature branch: git checkout -b my-new-feature
2. Commit your changes: git commit -am 'Add some feature'
3. Push to the branch: git push origin my-new-feature
4. Submit a pull request
## License
MIT