how to use proper subcommands in Django 1.8?

56 views
Skip to first unread message

bwv549

unread,
Oct 27, 2015, 11:22:40 AM10/27/15
to Django users
I realize that there is a LabelCommand, and that works for some things, but I would like full subcommand capabilities (in this case because I would like to have specific options for specific subcommands).

I can invoke add_subparsers inside of add_arguments, but when it gets to where you take the resulting subparsers object and 'add_parser' it chokes due to an incompatibility in the number of arguments expected.  I dug into the code, and this incompatibility appears to stem from the fact that django's CommandParser requires an extra argument (i.e., the name of the command) from what is given to initialize a new parser.  So, the code trying to create a new parser inside of the add_parser command is feeding it the wrong number of args (it's trying to merely give it the kwargs without the command).

Any direction would be greatly appreciated.

bwv549

unread,
Oct 27, 2015, 11:41:35 AM10/27/15
to Django users
I can get basic functionality through specifying the parser_class kwarg in my add_subparsers.  I've tried this both with ArgumentParser and with my own custom subclass of CommandParser that takes either CommandParser initialize methods or ArgumentParser style initialize methods.  However, I haven't been able to generate a proper help message for a subcommand with either of these.
Reply all
Reply to author
Forward
0 new messages