yargs 16.0.4-candidate.0 → 16.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +25 -6
- package/browser.mjs +4 -4
- package/build/index.cjs +348 -231
- package/build/lib/argsert.js +9 -5
- package/build/lib/command.js +44 -35
- package/build/lib/completion.js +27 -14
- package/build/lib/middleware.js +5 -3
- package/build/lib/parse-command.js +3 -3
- package/build/lib/usage.js +81 -47
- package/build/lib/utils/apply-extends.js +8 -7
- package/build/lib/utils/is-promise.js +2 -2
- package/build/lib/utils/obj-filter.js +1 -1
- package/build/lib/utils/set-blocking.js +4 -2
- package/build/lib/utils/which-module.js +1 -1
- package/build/lib/validation.js +37 -31
- package/build/lib/yargs-factory.js +126 -83
- package/helpers.mjs +7 -11
- package/index.cjs +17 -17
- package/index.mjs +5 -5
- package/lib/platform-shims/browser.mjs +38 -37
- package/package.json +31 -25
- package/yargs +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [16.1.0](https://www.github.com/yargs/yargs/compare/v16.0.3...v16.1.0) (2020-10-15)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* expose hideBin helper for CJS ([#1768](https://www.github.com/yargs/yargs/issues/1768)) ([63e1173](https://www.github.com/yargs/yargs/commit/63e1173bb47dc651c151973a16ef659082a9ae66))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **deno:** update types for deno ^1.4.0 ([#1772](https://www.github.com/yargs/yargs/issues/1772)) ([0801752](https://www.github.com/yargs/yargs/commit/080175207d281be63edf90adfe4f0568700b0bf5))
|
|
16
|
+
* **exports:** node 13.0-13.6 require a string fallback ([#1776](https://www.github.com/yargs/yargs/issues/1776)) ([b45c43a](https://www.github.com/yargs/yargs/commit/b45c43a5f64b565c3794f9792150eaeec4e00b69))
|
|
17
|
+
* **modules:** module path was incorrect ([#1759](https://www.github.com/yargs/yargs/issues/1759)) ([95a4a0a](https://www.github.com/yargs/yargs/commit/95a4a0ac573cfe158e6e4bc8c8682ebd1644a198))
|
|
18
|
+
* **positional:** positional strings no longer drop decimals ([#1761](https://www.github.com/yargs/yargs/issues/1761)) ([e1a300f](https://www.github.com/yargs/yargs/commit/e1a300f1293ad821c900284616337f080b207980))
|
|
19
|
+
* make positionals in -- count towards validation ([#1752](https://www.github.com/yargs/yargs/issues/1752)) ([eb2b29d](https://www.github.com/yargs/yargs/commit/eb2b29d34f1a41e0fd6c4e841960e5bfc329dc3c))
|
|
20
|
+
|
|
5
21
|
### [16.0.3](https://www.github.com/yargs/yargs/compare/v16.0.2...v16.0.3) (2020-09-10)
|
|
6
22
|
|
|
7
23
|
|
package/README.md
CHANGED
|
@@ -21,9 +21,22 @@ Yargs helps you build interactive command line tools, by parsing arguments and g
|
|
|
21
21
|
It gives you:
|
|
22
22
|
|
|
23
23
|
* commands and (grouped) options (`my-program.js serve --port=5000`).
|
|
24
|
-
* a dynamically generated help menu based on your arguments
|
|
24
|
+
* a dynamically generated help menu based on your arguments:
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
```
|
|
27
|
+
mocha [spec..]
|
|
28
|
+
|
|
29
|
+
Run tests with Mocha
|
|
30
|
+
|
|
31
|
+
Commands
|
|
32
|
+
mocha inspect [spec..] Run tests with Mocha [default]
|
|
33
|
+
mocha init <path> create a client-side Mocha setup at <path>
|
|
34
|
+
|
|
35
|
+
Rules & Behavior
|
|
36
|
+
--allow-uncaught Allow uncaught errors to propagate [boolean]
|
|
37
|
+
--async-only, -A Require all tests to use a callback (async) or
|
|
38
|
+
return a Promise [boolean]
|
|
39
|
+
```
|
|
27
40
|
|
|
28
41
|
* bash-completion shortcuts for commands and options.
|
|
29
42
|
* and [tons more](/docs/api.md).
|
|
@@ -46,7 +59,9 @@ npm i yargs@next
|
|
|
46
59
|
|
|
47
60
|
```javascript
|
|
48
61
|
#!/usr/bin/env node
|
|
49
|
-
const
|
|
62
|
+
const yargs = require('yargs/yargs')
|
|
63
|
+
const { hideBin } = require('yargs/helpers')
|
|
64
|
+
const argv = yargs(hideBin(process.argv)).argv
|
|
50
65
|
|
|
51
66
|
if (argv.ships > 3 && argv.distance < 53.5) {
|
|
52
67
|
console.log('Plunder more riffiwobbles!')
|
|
@@ -67,7 +82,10 @@ Retreat from the xupptumblers!
|
|
|
67
82
|
|
|
68
83
|
```javascript
|
|
69
84
|
#!/usr/bin/env node
|
|
70
|
-
require('yargs')
|
|
85
|
+
const yargs = require('yargs/yargs')
|
|
86
|
+
const { hideBin } = require('yargs/helpers')
|
|
87
|
+
|
|
88
|
+
yargs(hideBin(process.argv))
|
|
71
89
|
.command('serve [port]', 'start the server', (yargs) => {
|
|
72
90
|
yargs
|
|
73
91
|
.positional('port', {
|
|
@@ -108,7 +126,7 @@ As of `v16`, `yargs` supports [Deno](https://github.com/denoland/deno):
|
|
|
108
126
|
import yargs from 'https://deno.land/x/yargs/deno.ts'
|
|
109
127
|
import { Arguments, YargsType } from 'https://deno.land/x/yargs/types.ts'
|
|
110
128
|
|
|
111
|
-
yargs()
|
|
129
|
+
yargs(Deno.args)
|
|
112
130
|
.command('download <files...>', 'download a list of files', (yargs: YargsType) => {
|
|
113
131
|
return yargs.positional('files', {
|
|
114
132
|
describe: 'a list of files to do something with'
|
|
@@ -118,7 +136,7 @@ yargs()
|
|
|
118
136
|
})
|
|
119
137
|
.strictCommands()
|
|
120
138
|
.demandCommand(1)
|
|
121
|
-
.
|
|
139
|
+
.argv
|
|
122
140
|
```
|
|
123
141
|
|
|
124
142
|
### ESM
|
|
@@ -162,6 +180,7 @@ Having problems? want to contribute? join our [community slack](http://devtoolsc
|
|
|
162
180
|
* [Composing Your App Using Commands](/docs/advanced.md#commands)
|
|
163
181
|
* [Building Configurable CLI Apps](/docs/advanced.md#configuration)
|
|
164
182
|
* [Customizing Yargs' Parser](/docs/advanced.md#customizing)
|
|
183
|
+
* [Bundling yargs](/docs/bundling.md)
|
|
165
184
|
* [Contributing](/contributing.md)
|
|
166
185
|
|
|
167
186
|
## Supported Node.js Versions
|
package/browser.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Bootstrap yargs for browser:
|
|
2
|
-
import browserPlatformShim from './lib/platform-shims/browser.mjs'
|
|
3
|
-
import {
|
|
2
|
+
import browserPlatformShim from './lib/platform-shims/browser.mjs';
|
|
3
|
+
import {YargsWithShim} from './build/lib/yargs-factory.js';
|
|
4
4
|
|
|
5
|
-
const Yargs = YargsWithShim(browserPlatformShim)
|
|
5
|
+
const Yargs = YargsWithShim(browserPlatformShim);
|
|
6
6
|
|
|
7
|
-
export default Yargs
|
|
7
|
+
export default Yargs;
|