is it possible to extend subparsers new names without implementing all of their parameters twice?
I have a program, let's call it pgmm which has a sub function create. This create function needs a config file somewhere. To prevent looking for this, create can have the option --noconfig.
What I want now is to have some 'pseudo sub parser' maybe like init, which is basically the same as create --noconfig
I hope that there is a way without implementing the same twice..
is it?
I don't know of a way of adding this logic to
argparseper se, but you don't have to do that to get the behavior you want. You can create a subparser forcreateand addinitas an alias for that command so that either command name can be used. Then, when you consume the arguments after callingparse_args, check which subcommand was executed, and if it wasinit, then force thenoconfigflag toTrue: