Skip to content

Commit cf58455

Browse files
authored
Add tips about showing help instead of just missing arguments error (#1547)
* Add tips about showing help instead of just missing arguments error * Add block types. Fix indentation.
1 parent 9fad40f commit cf58455

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

CHANGELOG.md

+33
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
88
<!-- markdownlint-disable MD024 -->
99
<!-- markdownlint-disable MD004 -->
1010

11+
## [Unreleased] (date goes here)
12+
13+
### Migration Tips
14+
15+
If you have a simple program without an action handler, you will now get an error if
16+
there are missing command-arguments.
17+
18+
```js
19+
program
20+
.option('-d, --debug')
21+
.arguments('<file>');
22+
program.parse();
23+
```
24+
25+
```sh
26+
$ node trivial.js
27+
error: missing required argument 'file'
28+
```
29+
30+
If you want to show the help in this situation, you could check the arguments before parsing:
31+
32+
```js
33+
if (process.argv.length === 2)
34+
program.help();
35+
program.parse();
36+
```
37+
38+
Or, you might choose to show the help after any user error:
39+
40+
```js
41+
program.showHelpAfterError();
42+
```
43+
1144
## [8.0.0-2] (2021-06-06)
1245

1346
### Added

0 commit comments

Comments
 (0)