node_modules
.bin
accepts
after
array-flatten
arraybuffer.slice
async-limiter
backo2
base64-arraybuffer
base64id
better-assert
blob
callsite
commander
component-bind
component-emitter
component-inherit
content-disposition
content-type
cookie
cookie-signature
debug
depd
destroy
diff
ee-first
encodeurl
engine.io
engine.io-client
engine.io-parser
escape-html
escape-string-regexp
etag
express
finalhandler
forwarded
fresh
glob
growl
has-binary2
has-cors
http-errors
indexof
inherits
ipaddr.js
isarray
jade
lru-cache
media-typer
merge-descriptors
methods
mime
mime-db
mime-types
minimatch
minimist
example
test
.travis.yml
LICENSE
index.js
package.json
readme.markdown
mkdirp
mocha
ms
negotiator
net
object-component
on-finished
parseqs
parseuri
parseurl
path-to-regexp
proxy-addr
qs
quick-local-ip
range-parser
safe-buffer
send
serve-static
setprototypeof
sigmund
socket.io
socket.io-adapter
socket.io-client
socket.io-parser
statuses
supports-color
to-array
to-iso-string
type-is
ultron
unpipe
utils-merge
vary
ws
xmlhttprequest-ssl
yeast
public
README.md
index.js
package-lock.json
package.json
74 lines
1.6 KiB
Markdown
74 lines
1.6 KiB
Markdown
# minimist
|
|
|
|
parse argument options
|
|
|
|
This module is the guts of optimist's argument parser without all the
|
|
fanciful decoration.
|
|
|
|
[](http://ci.testling.com/substack/minimist)
|
|
|
|
[](http://travis-ci.org/substack/minimist)
|
|
|
|
# example
|
|
|
|
``` js
|
|
var argv = require('minimist')(process.argv.slice(2));
|
|
console.dir(argv);
|
|
```
|
|
|
|
```
|
|
$ node example/parse.js -a beep -b boop
|
|
{ _: [], a: 'beep', b: 'boop' }
|
|
```
|
|
|
|
```
|
|
$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
|
|
{ _: [ 'foo', 'bar', 'baz' ],
|
|
x: 3,
|
|
y: 4,
|
|
n: 5,
|
|
a: true,
|
|
b: true,
|
|
c: true,
|
|
beep: 'boop' }
|
|
```
|
|
|
|
# methods
|
|
|
|
``` js
|
|
var parseArgs = require('minimist')
|
|
```
|
|
|
|
## var argv = parseArgs(args, opts={})
|
|
|
|
Return an argument object `argv` populated with the array arguments from `args`.
|
|
|
|
`argv._` contains all the arguments that didn't have an option associated with
|
|
them.
|
|
|
|
Numeric-looking arguments will be returned as numbers unless `opts.string` or
|
|
`opts.boolean` is set for that argument name.
|
|
|
|
Any arguments after `'--'` will not be parsed and will end up in `argv._`.
|
|
|
|
options can be:
|
|
|
|
* `opts.string` - a string or array of strings argument names to always treat as
|
|
strings
|
|
* `opts.boolean` - a string or array of strings to always treat as booleans
|
|
* `opts.alias` - an object mapping string names to strings or arrays of string
|
|
argument names to use as aliases
|
|
* `opts.default` - an object mapping string argument names to default values
|
|
|
|
# install
|
|
|
|
With [npm](https://npmjs.org) do:
|
|
|
|
```
|
|
npm install minimist
|
|
```
|
|
|
|
# license
|
|
|
|
MIT
|