arnaucube
arnaucube/socketioMEANseedPublic Self-hosted repository
socketioMEANseed/www/node_modules/minimist/readme.markdown
www/node_modules/minimist/readme.markdownRaw
 1# minimist
 2
 3parse argument options
 4
 5This module is the guts of optimist's argument parser without all the
 6fanciful decoration.
 7
 8[![browser support](https://ci.testling.com/substack/minimist.png)](http://ci.testling.com/substack/minimist)
 9
10[![build status](https://secure.travis-ci.org/substack/minimist.png)](http://travis-ci.org/substack/minimist)
11
12# example
13
14``` js
15var argv = require('minimist')(process.argv.slice(2));
16console.dir(argv);
17```
18
19```
20$ node example/parse.js -a beep -b boop
21{ _: [], a: 'beep', b: 'boop' }
22```
23
24```
25$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
26{ _: [ 'foo', 'bar', 'baz' ],
27  x: 3,
28  y: 4,
29  n: 5,
30  a: true,
31  b: true,
32  c: true,
33  beep: 'boop' }
34```
35
36# methods
37
38``` js
39var parseArgs = require('minimist')
40```
41
42## var argv = parseArgs(args, opts={})
43
44Return an argument object `argv` populated with the array arguments from `args`.
45
46`argv._` contains all the arguments that didn't have an option associated with
47them.
48
49Numeric-looking arguments will be returned as numbers unless `opts.string` or
50`opts.boolean` is set for that argument name.
51
52Any arguments after `'--'` will not be parsed and will end up in `argv._`.
53
54options can be:
55
56* `opts.string` - a string or array of strings argument names to always treat as
57strings
58* `opts.boolean` - a boolean, string or array of strings to always treat as
59booleans. if `true` will treat all double hyphenated arguments without equal signs
60as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
61* `opts.alias` - an object mapping string names to strings or arrays of string
62argument names to use as aliases
63* `opts.default` - an object mapping string argument names to default values
64* `opts.stopEarly` - when true, populate `argv._` with everything after the
65first non-option
66* `opts['--']` - when true, populate `argv._` with everything before the `--`
67and `argv['--']` with everything after the `--`. Here's an example:
68* `opts.unknown` - a function which is invoked with a command line parameter not
69defined in the `opts` configuration object. If the function returns `false`, the
70unknown option is not added to `argv`.
71
72```
73> require('./')('one two three -- four five --six'.split(' '), { '--': true })
74{ _: [ 'one', 'two', 'three' ],
75  '--': [ 'four', 'five', '--six' ] }
76```
77
78Note that with `opts['--']` set, parsing for arguments still stops after the
79`--`.
80
81# install
82
83With [npm](https://npmjs.org) do:
84
85```
86npm install minimist
87```
88
89# license
90
91MIT