-
Notifications
You must be signed in to change notification settings - Fork 150
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
Minimize boilerplate when building Commands/Options #4292
base: develop
Are you sure you want to change the base?
Conversation
Current issue I'm having: Edit: I solved this for now by using a separate class for each type of option we might want to have, some of which have special features, e.g. |
pyk/src/pyk/cli/cli.py
Outdated
optional: bool = False, | ||
help_str: str | None = None, | ||
metavar: str | None = None, | ||
default: Any = 'NoDefault', |
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.
Consider introducing a dedicated value (a null object) for this, e.g.
NO_DEFAULT: Final = object()
pyk/src/pyk/cli/cli.py
Outdated
) | ||
|
||
|
||
class BoolOption(Option): |
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.
It'd be best to avoid the need for this class hierarchy. It is possible I'm missing something, but I think you can just add to Option
all the attributes necessary to call add_argument
.
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 was looking to hide the argparse implementation details, like FileType
, but I guess this is not really necessary.
No description provided.