You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+91-16Lines changed: 91 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,27 +3,89 @@
3
3
4
4
[![Coverage][coverage-image]][coverage-url]
5
5
6
-
>
7
-
> π¨ THIS REPO IS AN EARLY WIP -- DO NOT USE ... yet π¨
8
-
>
9
-
10
-
Polyfill of future proposal to the [nodejs/tooling](https://github.com/nodejs/tooling) repo for `util.parseArgs()`
11
-
12
-
### Scope
13
-
14
-
It is already possible to build great arg parsing modules on top of what Node.js provides; the prickly API is abstracted away by these modules. Thus, process.parseArgs() is not necessarily intended for library authors; it is intended for developers of simple CLI tools, ad-hoc scripts, deployed Node.js applications, and learning materials.
15
-
16
-
It is exceedingly difficult to provide an API which would both be friendly to these Node.js users while being extensible enough for libraries to build upon. We chose to prioritize these use cases because these are currently not well-served by Node.js' API.
6
+
Polyfill of proposal for `util.parseArgs()`
7
+
8
+
## `util.parseArgs([config])`
9
+
10
+
<!-- YAML
11
+
added: REPLACEME
12
+
-->
13
+
14
+
> Stability: 1 - Experimental
15
+
16
+
*`config` {Object} Used to provide arguments for parsing and to configure
17
+
the parser. `config` supports the following properties:
18
+
*`args` {string\[]} array of argument strings. **Default:**`process.argv`
19
+
with `execPath` and `filename` removed.
20
+
*`options` {Object} Used to describe arguments known to the parser.
21
+
Keys of `options` are the long names of options and values are an
22
+
{Object} accepting the following properties:
23
+
*`type` {string} Type of argument, which must be either `boolean` or `string`.
24
+
**Default:**`boolean`.
25
+
*`multiple` {boolean} Whether this option can be provided multiple
26
+
times. If `true`, all values will be collected in an array. If
27
+
`false`, values for the option are last-wins. **Default:**`false`.
28
+
*`short` {string} A single character alias for the option.
29
+
*`strict`: {boolean} Should an error be thrown when unknown arguments
30
+
are encountered, or when arguments are passed that do not match the
31
+
`type` configured in `options`.
32
+
**Default:**`true`.
33
+
34
+
* Returns: {Object} An {Object} representing the parsed command line
35
+
arguments:
36
+
*`values` {Object} With properties and {string} or {boolean} values
@@ -32,7 +94,13 @@ It is exceedingly difficult to provide an API which would both be friendly to th
32
94
-[π Examples](#-examples)
33
95
-[F.A.Qs](#faqs)
34
96
35
-
----
97
+
-----
98
+
99
+
## Scope
100
+
101
+
It is already possible to build great arg parsing modules on top of what Node.js provides; the prickly API is abstracted away by these modules. Thus, process.parseArgs() is not necessarily intended for library authors; it is intended for developers of simple CLI tools, ad-hoc scripts, deployed Node.js applications, and learning materials.
102
+
103
+
It is exceedingly difficult to provide an API which would both be friendly to these Node.js users while being extensible enough for libraries to build upon. We chose to prioritize these use cases because these are currently not well-served by Node.js' API.
0 commit comments