source: trip-planner-front/node_modules/minimist/readme.markdown@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.4 KB
Line 
1# minimist
2
3parse argument options
4
5This module is the guts of optimist's argument parser without all the
6fanciful decoration.
7
8# example
9
10``` js
11var argv = require('minimist')(process.argv.slice(2));
12console.log(argv);
13```
14
15```
16$ node example/parse.js -a beep -b boop
17{ _: [], a: 'beep', b: 'boop' }
18```
19
20```
21$ node example/parse.js -x 3 -y 4 -n5 -abc --beep=boop foo bar baz
22{ _: [ 'foo', 'bar', 'baz' ],
23 x: 3,
24 y: 4,
25 n: 5,
26 a: true,
27 b: true,
28 c: true,
29 beep: 'boop' }
30```
31
32# security
33
34Previous versions had a prototype pollution bug that could cause privilege
35escalation in some circumstances when handling untrusted user input.
36
37Please use version 1.2.3 or later: https://snyk.io/vuln/SNYK-JS-MINIMIST-559764
38
39# methods
40
41``` js
42var parseArgs = require('minimist')
43```
44
45## var argv = parseArgs(args, opts={})
46
47Return an argument object `argv` populated with the array arguments from `args`.
48
49`argv._` contains all the arguments that didn't have an option associated with
50them.
51
52Numeric-looking arguments will be returned as numbers unless `opts.string` or
53`opts.boolean` is set for that argument name.
54
55Any arguments after `'--'` will not be parsed and will end up in `argv._`.
56
57options can be:
58
59* `opts.string` - a string or array of strings argument names to always treat as
60strings
61* `opts.boolean` - a boolean, string or array of strings to always treat as
62booleans. if `true` will treat all double hyphenated arguments without equal signs
63as boolean (e.g. affects `--foo`, not `-f` or `--foo=bar`)
64* `opts.alias` - an object mapping string names to strings or arrays of string
65argument names to use as aliases
66* `opts.default` - an object mapping string argument names to default values
67* `opts.stopEarly` - when true, populate `argv._` with everything after the
68first non-option
69* `opts['--']` - when true, populate `argv._` with everything before the `--`
70and `argv['--']` with everything after the `--`. Here's an example:
71
72 ```
73 > require('./')('one two three -- four five --six'.split(' '), { '--': true })
74 { _: [ 'one', 'two', 'three' ],
75 '--': [ 'four', 'five', '--six' ] }
76 ```
77
78 Note that with `opts['--']` set, parsing for arguments still stops after the
79 `--`.
80
81* `opts.unknown` - a function which is invoked with a command line parameter not
82defined in the `opts` configuration object. If the function returns `false`, the
83unknown option is not added to `argv`.
84
85# install
86
87With [npm](https://npmjs.org) do:
88
89```
90npm install minimist
91```
92
93# license
94
95MIT
Note: See TracBrowser for help on using the repository browser.