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 error() for displaying errors from client code #1675

Merged
merged 6 commits into from Jan 14, 2022

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Jan 8, 2022

Pull Request

Problem

People adding extra error checks do not have a way to take advantage of the error configuration built into Commander such as: .configureOutput(), .exitOverride(), .showHelpAfterError().

There have not been many requests for this, but we do now have quite rich error handling which clients can use for their own errors too.

Related: #1358 #1632

Solution

Provide a low level routine that is also used by Commander itself. Refactor private ._displayError() into public .error(). Change the signature to make the error id code and exitCode optional so can be called with just a message.

if (cmd.opts().good && cmd.opts().bad)
  cmd.error('error: specify just one of "--good" and "--bad"');

ChangeLog

  • add error() for generating errors from client code just like Commander generated errors, with support for .configureOutput(), .exitOverride(), and .showHelpAfterError()

@shadowspawn shadowspawn added the semver: major Releasing requires a major version bump, not backwards compatible label Jan 8, 2022
@shadowspawn shadowspawn marked this pull request as ready for review January 13, 2022 08:23
Copy link
Collaborator

@abetomo abetomo left a comment

Choose a reason for hiding this comment

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

awesome!

@shadowspawn shadowspawn merged commit 7a59df4 into tj:release/9.x Jan 14, 2022
@shadowspawn shadowspawn deleted the feature/error2 branch January 14, 2022 09:44
@shadowspawn
Copy link
Collaborator Author

Thanks @abetomo
I will do another prerelease soon. No other changes in mind!

@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Jan 14, 2022
@shadowspawn shadowspawn added this to the Commander v9.0.0 milestone Jan 14, 2022
@shadowspawn
Copy link
Collaborator Author

.error() is included in prerelease Commander v9.0.0-1.

Readme.md Show resolved Hide resolved
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Jan 29, 2022
@shadowspawn
Copy link
Collaborator Author

Commander v9 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: major Releasing requires a major version bump, not backwards compatible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants