-
Notifications
You must be signed in to change notification settings - Fork 53
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
Use argparse subparsers for subcommands #80
Conversation
Hi @csomh. Thanks for your PR. I'm waiting for a operator-framework or openshift member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What is the advantage of using Also, #77 should be solved by a separate pr. Please do not co-mingle multiple changes in a single pull request. |
Subparsers are the argparse provided way to handle subcommands. Switching to this was easier than figuring out the bug in the custom implementation, which was causing #77 or led to an incorrect usage text to be displayed for subcommands. Sorry, the commit message didn't clarify this. Updated it, together with the initial PR comment. |
How do you know that there was a bug at all? It seems like the command has description output, and I'm not sure that your change fixed any bug at all. It seems more likely to me that the issue in question was describing a perceived lack of documentation about what the flag outputs (aside from the very basic description of the flag). That could be a separate discussion, but I don't think this PR fixes the issue. And, again, I still don't see what using |
Oh, ok, I see now. You're right. |
This PR is still valid (but must be updated), There were already several issues caused by not using subparsers. |
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.
Please update the commit message to stop referencing #77 since this does not resolve the issue, and please give a more detailed description of what problems this implementation resolves.
Makes argument parsing more resilient, by handling subcommands with argparse provided and recommended [subparsers][1], instead of the current custom manipulation of argv. Removes the need to manually update and format the top-level help message: this is going to be composed from the help strings of the subcommands by argparse. Fixes the issue of subcommand's usage string not displaying the subcommand. Removes the need to explicitly check for incorrect subcommands. Enables extending the CLI with top-level optional arguments, without the need of adjusting argv parsing. [1]: https://docs.python.org/3/library/argparse.html#sub-commands Signed-off-by: Hunor Csomortáni <[email protected]>
Updated. |
/lgtm |
works for me |
Makes argument parsing more resilient, by handling
subcommands with argparse provided and recommended subparsers,
instead of the current custom manipulation of argv.
Removes the need to manually update and format the top-level
help message: this is going to be composed from the help strings
of the subcommands by argparse.
Fixes the issue of subcommand's usage string not displaying the
subcommand.
Removes the need to explicitly check for incorrect subcommands.
Enables extending the CLI with top-level optional arguments, without the
need of adjusting argv parsing.