Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate choices in help with short/long arguments #133

Closed
BrendanSimon opened this issue Oct 19, 2018 · 1 comment
Closed

duplicate choices in help with short/long arguments #133

BrendanSimon opened this issue Oct 19, 2018 · 1 comment
Labels

Comments

@BrendanSimon
Copy link

If I specify a short and long argument with a boolean default, I get something like:
-u, --upper False

If I specifiy an argument with choices, I get both arguments listed, each with it's own set of (duplicated) choices.
-f {yaml,json}, --format {yaml,json}

It would be better to have both arguments lists, but only one set of choices - something like:
-f, --format {yaml,json}

Here is some sample code:

from argh import *

@dispatch_command
@arg('name')
@arg('-f', '--format', choices=['yaml','json'])
@arg('-u', '--upper')
def main(name, format='json', upper=False):
    msg='Hello {} (format={})'.format(name, format)
    if upper:
        msg = msg.upper()
    print(msg)

and sample output:

$ python3.6 foo.py -h
usage: foo.py [-h] [-f {yaml,json}] [-u] name

positional arguments:
  name                  -

optional arguments:
  -h, --help            show this help message and exit
  -f {yaml,json}, --format {yaml,json}
                        'json'
  -u, --upper           False

@neithere
Copy link
Owner

This is a good observation. However, I'm afraid the help is generated by Argparse. Not sure if we can affect this on Argh level in a sensible way. Please feel free to reopen if you have an idea how to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants