From cf58455f038480131d01411bb60c736f32a217ca Mon Sep 17 00:00:00 2001 From: John Gee Date: Mon, 14 Jun 2021 08:38:25 +1200 Subject: [PATCH] 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. --- CHANGELOG.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8861c627a..320aef43e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. +## [Unreleased] (date goes here) + +### Migration Tips + +If you have a simple program without an action handler, you will now get an error if +there are missing command-arguments. + +```js +program + .option('-d, --debug') + .arguments(''); +program.parse(); +``` + +```sh +$ node trivial.js +error: missing required argument 'file' +``` + +If you want to show the help in this situation, you could check the arguments before parsing: + +```js +if (process.argv.length === 2) + program.help(); +program.parse(); +``` + +Or, you might choose to show the help after any user error: + +```js +program.showHelpAfterError(); +``` + ## [8.0.0-2] (2021-06-06) ### Added