classification
Title: argparse: add a full fledged parser as a subparser
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: porton, terry.reedy
Priority: normal Keywords:

Created on 2018-12-13 01:44 by porton, last changed 2018-12-14 21:48 by terry.reedy. This issue is now closed.

Messages (3)
msg331730 - (view) Author: Victor Porton (porton) Date: 2018-12-13 01:44
Subparsers are added like:

subparsers.add_parser('checkout', aliases=['co'])

But I want to use a parser BOTH as a subparser and as a full-fledged parser.

It is because my program should understand both of the following command line options:

boiler chain -t http://www.w3.org/1999/xhtml -W inverseofsum

and

boiler pipe 'chain -t http://www.w3.org/1999/xhtml -W inverseofsum + transformation http://example.com/ns1'.

I split it (at +) into several lists of arguments as explained in https://stackoverflow.com/a/53750697/856090

So I need `chain` both as a subparser and as a standalone parser of `-t http://www.w3.org/1999/xhtml -W inverseofsum`.

So, feature which I want:

subparsers.add_parser('checkout', aliases=['co'], parser=...)

where ... is a reference to a parser object.
msg331734 - (view) Author: Victor Porton (porton) Date: 2018-12-13 02:01
Oh, I noticed I can do

my_subparser = subparsers.add_parser('checkout', aliases=['co'])

So resolution invalid.
msg331874 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-12-14 21:48
I presume you mean to close this.
History
Date User Action Args
2018-12-14 21:48:58terry.reedysetstatus: open -> closed

nosy: + terry.reedy
messages: + msg331874

stage: resolved
2018-12-13 02:01:13portonsetresolution: not a bug
messages: + msg331734
2018-12-13 01:44:37portoncreate