-
Notifications
You must be signed in to change notification settings - Fork 72
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
config: Improve input checking in config command #209
Conversation
Previously you could use config to set an invalid value, which would prevent you from ever running config again to fix it. - Run config before loading the parsed config into args. This ensures that invalid config files won't prevent running config, and config itself can't be configured anyway. - Add a --delete option to config to delete keys - Validate that the given config command and option are actually valid. if invalid, suggest a list of valid options. - Error out if the provided value is invalid for the given option, and also add choices to the validity check. Topic: improveconfig Reviewers: aaron, brian-k
Reviews in this chain: |
|
2c402d3
to
eea3ccd
Compare
cce56da
to
59bcdde
Compare
59bcdde
to
1bb71de
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice
elif option_string.startswith("-"): | ||
no_options.append("-n" + option_string[1:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this idiomatic? I tend to think short cli args can be stacked like tool -abcdef
, and yeah that's how argparse works also: https://docs.python.org/3/library/argparse.html#option-value-syntax
It seems like it'd be confusing to pass e.g. -nx
and not know if that's short for -n -x
or --no-xlong-argument
, I think the way revup is set up here it'd always be --no-xlong-argument
but I'm not sure if I've seen a cli tool where that'd be the case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah true, fwiw we don't have any flags that use -n for roughly this reason (except stragglers in toolkit that can be changed) would this be better if we formalized that?
we can also get rid of the short syntax and use only --no- longform syntax, i'm not that attached to it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather use only --no-
longform
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sg i'll make that a new pr though, its not strictly related to this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
Previously you could use config to set an invalid value, which would
prevent you from ever running config again to fix it.
Run config before loading the parsed config into args. This ensures
that invalid config files won't prevent running config, and config itself can't
be configured anyway.
Add a --delete option to config to delete keys
Validate that the given config command and option are actually valid. if invalid,
suggest a list of valid options.
Error out if the provided value is invalid for the given option, and also add
choices to the validity check.
Topic: improveconfig
Reviewers: aaron, brian-k