A simple POSIX-style command line argument parsing module with no dependencies and no required configuration.
npm install quasix-getoptThis module does not parse POSIX.1-2008 or any other official
specification. This module parses the following simple POSIX-like
constructs.
-a```
{
a: true
}
* single-dash combined arguments: -zxvpf
``
{
z: true,
x: true,
v: true,
p: true,
f: true
}
* single-dash combined arguments with a bare value following: -zxvpf blah.tgz
``
{
z: true,
x: true,
v: true,
p: true,
f: true,
_extras: ['blah.tgz']
}
* single-dash arguments with value: -o data.txt
``
{
o: data.txt
}
* single-dash arguments with value indicated with equal =: -o=data.txt
``
{
o: data.txt
}
* double-dash arguments: --verbose
``
{
verbose: true
}
* double-dash arguments with value: --outfile data.txt
``
{
outfile: data.txt
}
* double-dash arguments with value indicated with equal =: --outfile=data.txt
``
{
outfile: data.txt
}
* bare keywords: add default gw 192.168.1.10
``
{
_extras: ['add', 'default', 'gw', '192.168.1.10']
}
These syntaxes are not parsed as expected.
* single-dash multi-letter option names, like route's -net argument. Example: route add -net 12.34.0.0 netmask 255.255.0.0 gw 12.34.56.1 Result:
```
{
n: true,
e: true,
t: true,
_extras: ['add', '12.34.0.0', 'netmask', '255.255.0.0', 'gw', '12.34.56.1']
}
const quasix = require('quasix-getopt')
const options = quasix.parse()