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

Print all the missing options in the error message #367

Closed
vlsi opened this issue Aug 3, 2022 · 1 comment
Closed

Print all the missing options in the error message #367

vlsi opened this issue Aug 3, 2022 · 1 comment

Comments

@vlsi
Copy link

vlsi commented Aug 3, 2022

Thanks for the library!
I'm using it to drive Bugzilla -> GitHub issues conversion tool: https://github.com/vlsi/bugzilla2github

I noticed that currently Clikt prints only the first
The current behavior is Clikt stops at the first missing option, so the user has to re-run the command adding options one by one.

It would be nice if Clikt could collect and print all the failures at once (missing options, invalid values, etc)

class ManyOpts: NoOpCliktCommand() {
    val int by option().int().required()
    val string by option().required()
}
$ .. many-opts

Usage: root many-opts [OPTIONS]

Error: Missing option "--int"

I would expect that the error message would include all the missing options rather than just the first.

$ .. many-opts --int=1

Usage: root many-opts [OPTIONS]

Error: Missing option "--string"

So the user has to add options one-by-one.

The same goes when there's an error (it would be nice for the error message to include all the missing required options and all the options that can't be parsed):

$ .. many-opts --int=undefined

Usage: root many-opts [OPTIONS]

Error: Invalid value for "--int": undefined is not a valid integer
@ajalt
Copy link
Owner

ajalt commented Aug 21, 2022

I implemented this in the latest snapshot on the 4.0 branch. Give it a try.

Keep in mind that it's not possible to print every combination of errors every time, since some errors cause subsequent parsing to become ambiguous.

@ajalt ajalt closed this as completed Aug 21, 2022
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