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

Support error messages #2

Closed
ewels opened this issue Feb 9, 2022 · 4 comments
Closed

Support error messages #2

ewels opened this issue Feb 9, 2022 · 4 comments
Labels
new feature New feature or request

Comments

@ewels
Copy link
Owner

ewels commented Feb 9, 2022

Currently, error messages from non-existent flags etc are not formatted. It would be good to give these consistent formatting.

image

I would be surprised if there are also other types of Click output which are also missing.

@ewels ewels added the new feature New feature or request label Feb 10, 2022
@ewels
Copy link
Owner Author

ewels commented Feb 10, 2022

Looks like error messages are printed by raising a click.UsageError.

Need to track down where these are handled so that we can format printing the output. I guess this will mean monkey patching another function call 😕

@ewels
Copy link
Owner Author

ewels commented Feb 15, 2022

Docs about exception handling here: https://click.palletsprojects.com/en/8.0.x/exceptions/

Ah, after a bit of digging, I think this is probably the code that we want to customise: https://github.com/pallets/click/blob/6411f425fae545f42795665af4162006b36c5e4a/src/click/exceptions.py#L39-L43

ewels added a commit that referenced this issue Feb 15, 2022
@ewels
Copy link
Owner Author

ewels commented Feb 15, 2022

ok, that worked - got basic support now:

image

The click function has more complex code for UsageErrors which I haven't ported yet, so will leave this issue open until then.

This code also adds the need for more monkey patching lines, so it'll be better after #10 is merged.

@ewels
Copy link
Owner Author

ewels commented Feb 17, 2022

Now finally finished in #10 - working fully as expected I think 👍🏻

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

No branches or pull requests

1 participant