-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
It would be great to be able to take advantage of argparse's ability to give subcommands one or more aliases. Example of help output in plain argparse:
delete-files (df) cause the files to be deleted
reload-files (rf) cause the files to be reloaded
validate-files (vf)
cause the files to be validated
Equivalent in plain argparse
:
subparser = parser.add_parser('delete-files',
aliases=['df'],
description='Subcommand for deleting files',
help='cause the files to be deleted')
and similar. Of course currently there are any number of workarounds -- in my projects I'm working on, I do things like:
class MyModel(BaseModel):
delete_files: Optional[DeleteFilesModel] = Field(description='cause the files to be deleted', alias='delete-files')
df: Optional[DeleteFilesModel] = Field(description='synonym for: delete-files')
etc. but it results in longer help output:
delete-files cause the files to be deleted
df synonym for: delete-files
reload-files cause the files to be reloaded
rf synonym for: reload-files
validate-files cause the files to be validated
vf synonym for: validate-files
Note that there's a difference in need between alias='delete-files'
and aliases=['df']
so having both alias
and aliases
might be very confusing; perhaps aliases
needs to be something like subcommand_aliases
.
Thanks for considering!
Metadata
Metadata
Assignees
Labels
No labels