Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alexbinary/tinyclap

a tiny command line argument parser for Node.js
https://github.com/alexbinary/tinyclap

Last synced: 1 day ago
JSON representation

a tiny command line argument parser for Node.js

Awesome Lists containing this project

README

        

# tinyclap - A tiny command line arguments parser for Node.js

```
npm install tinyclap
```

Example program :

```javascript
var clap = require('tinyclap')();
console.log(clap);
```

Input :

```
node index.js command
-a
-b42
-c=88
-d 21
-ef
-gh5
-foo=bar
--mn6
--opt1 value1
--opt2=value2
--opt3="value with spaces"
--long-option-with-dashes
--long-option-with-value1=10
--long-option-with-value2 20
otherthing
```

Output :

```
{ node: '/usr/bin/node',
file: '/home/john/index.js',
cmd: 'command'
argv:
{ '5': true,
a: true,
b: 42,
c: '88',
d: '21',
e: true,
f: true,
g: true,
h: true,
foo: 'bar',
mn6: true,
opt1: 'value1',
opt2: 'value2',
opt3: 'value with spaces',
'long-option-with-dashes': true,
'long-option-with-value1': '10',
'long-option-with-value2': '20' },
argn:
[ 'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'5',
'foo',
'mn6',
'opt1',
'opt2',
'opt3',
'long-option-with-dashes',
'long-option-with-value1',
'long-option-with-value2',
'otherthing' ],
}
```

# Contact

Alexandre Bintz
Comments and suggestions are welcome.