command.py: use argparse subparsers #47
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.