Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aleclarson/slurm
CLI argument parser
https://github.com/aleclarson/slurm
argv cli nodejs
Last synced: 19 days ago
JSON representation
CLI argument parser
- Host: GitHub
- URL: https://github.com/aleclarson/slurm
- Owner: aleclarson
- License: mit
- Created: 2018-03-23T01:40:07.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-27T21:38:43.000Z (almost 4 years ago)
- Last Synced: 2024-10-13T04:05:55.789Z (24 days ago)
- Topics: argv, cli, nodejs
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# slurm v0.5.9
CLI argument parser
```js
const slurm = require('slurm')const argv = '-f -b=0 --list 1 2 3 -n=100 --func [1,2,3] -xyz'
process.argv.push(...argv.split(' '))const args = slurm({
'*': true, // (no throw for unknown flags)
f: 'foo', // -f (alias of --foo)
foo: true, // --foo
list: { // --list 1 2 3
list: true
},
b: { // -b=0
type: 'boolean'
},
n: { // -n=100
type: 'number',
default: 0,
},
func(value) { // --func [1,2,3]
return JSON.parse(value)
}
})args.foo // => true
args.list // => ['1', '2', '3']
args.b // => false
args.n // => 100
args.func // => [1, 2, 3]
args.x // => true
args.y // => true
args.z // => true
```