nested subparsers with argparse

C

Chris Withers

Hi All,

I'm looking to build a script that has command line options as follows:

../myscript.py command subcommand [options]

I can do up to the command [options] bit with add_subparsers in
argparse, but how do I then add a second level of subparsers?

cheers,

Chris
 
P

Peter Otten

Chris said:
I'm looking to build a script that has command line options as follows:

./myscript.py command subcommand [options]

I can do up to the command [options] bit with add_subparsers in
argparse, but how do I then add a second level of subparsers?

It looks like subparsers behave like the toplevel parsers -- you can invoke
add_subparsers() on them, too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top