How to use argparse to collect arguments for a separate command line without --?
Pergunta
I'm writing Python programs that run other programs, like:
my-wrapper-program --foo --bar git commit --all
Here, foo and bar are arguments to my-wrapper-program, and git commit --all
is the sub-command I'm interested in running. How do I do this in argparse, without having to always specify the --
special argument? (The common case is the simplest one: my-wrapper-program command
.)
(With optparse, you can use disallow_interspersed_args=False
.)
Solução
This page has some suggestions.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow