command.py: use argparse subparsers#47
command.py: use argparse subparsers#47himdel merged 5 commits intoansible:mainfrom himdel:command-parse
Conversation
|
Seems to work without breaking stuff for CI .. ansible/ansible-hub-ui#2096 (https://github.com/ansible/ansible-hub-ui/runs/6553850868?check_suite_focus=true) |
|
Cc @hendersonreed this is my attempt to revive the command.py refactor by doing the minimum needed to get argparse parsing all the options instead of us splitting (If this makes sense, we can follow up with taking the command cleanup parts from #30, adding more help strings, etc.) |
hendersonreed
left a comment
There was a problem hiding this comment.
I think this is necessary, and all current QE environments using galaxykit are using an older version. If this does break them, we should update them when it comes time (but I don't think it does.)
IMO this is safe to merge to master for sure - all QE use is with versions that are released in PyPI.
This is trying to do a similar thing to #30 , but reducing the scope to just moving all custom param parsing to argparse subparsers with no syntax changes and no DRYing up the actual commands yet.
The effect should be better help, more reliable failures with unexpected param counts, and ability to add named arguments easily.
(
helpdescription can be added to eachkind,op,subopandarg, but it can be done gradually, mostly leaving out of this PR; It looks #30 has a lot more help text ready.)(
args.functionis also out of scope, for now just having the subparserdest=to the original arg name (kind,operation,subop))(
args.restis gone now)Renaming
args.username&args.passwordtoargs.auth_usernameandargs.auth_password, to prevent clashes with theusernameandpasswordpositional arguments foruser create. (versionwould also conflict but main usesaction="version", notaction="store")Also adding
--debugand--versionparams, andadmindefault values forusernameandpassword.