Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tips about showing help instead of just missing arguments error #1547

Merged
merged 2 commits into from Jun 13, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
<!-- markdownlint-disable MD024 -->
<!-- markdownlint-disable MD004 -->

## [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.

```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an indent width of 2 is better.
Because other code examples are 2.

It would be nice to have a highlight setting as well. ```js

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

program
.option('-d, --debug')
.arguments('<file>');
program.parse();
```

```
$ 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:

```
if (process.argv.length === 2)
program.help();
program.parse();
```

Or, you might choose to show the help after any user error:

```
program.showHelpAfterError();
```

## [8.0.0-2] (2021-06-06)

### Added
Expand Down