[issue45275] Make argparse print description of subcommand when invoke help doc on subcommand

Nikita Sobolev report at bugs.python.org
Sat Sep 25 03:43:05 EDT 2021


Nikita Sobolev <mail at sobolevn.me> added the comment:

Hi!

>From your description it is not clear how exactly you create your subcommand.

>From my experience, it works. Demo:

```
import argparse

parser = argparse.ArgumentParser(description='Process some integers.')
subparsers = parser.add_subparsers()

# create the parser for the "a" command
parser_a = subparsers.add_parser('a', help='a help', description='test me')
parser_a.add_argument('bar', type=int, help='bar help')

print(parser.parse_args())
```

Here's the output of `python script.py a -h`:

```
usage: ex.py a [-h] bar

test me

positional arguments:
  bar         bar help

options:
  -h, --help  show this help message and exit
```

Do you have the same setup? Or is there anything else that needs to be fixed?

----------
nosy: +sobolevn

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45275>
_______________________________________


More information about the Python-bugs-list mailing list