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

Client: support exit-code mapping just as the builder #914

Open
epa095 opened this issue Feb 4, 2020 · 2 comments
Open

Client: support exit-code mapping just as the builder #914

epa095 opened this issue Feb 4, 2020 · 2 comments

Comments

@epa095
Copy link
Contributor

epa095 commented Feb 4, 2020

The builer maps exceptions to exit codes. It makes sense to do the same in the client, and using the same mapping.

@epa095
Copy link
Contributor Author

epa095 commented Feb 18, 2020

Yo @milesgranger , I feel like it should be possible to make Click catch the exceptions and do the mapping for all sub-commands of the gordo command, but I did not figure out how to do it.

@milesgranger
Copy link
Contributor

It seems we could inherit click.ClickException and set our desired exit_code.

class CustomException(click.ClickException):
    exit_code = 21

@click.command()
def foo():
    raise CustomException('Noob!')

Running foo will give an exit code of 21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants