Skip to content

Add ability to display long options in usage message  #231

Open

Description

@mjreed-wbd

Is your feature request related to a problem?

I have a command with boolean flags which all have descriptive names, but the default usage message shortens all of them to just their first letters.

Describe the solution you'd like

I would like a way to specify, perhaps with the @arg decorator, that a boolean flag should be listed in the usage message in long form rather than short. It's nice that I can see the long form and my custom description via "--help", but I'd prefer to see the long form also in the short message you get when not providing the required parameters.

Describe alternatives you've considered

The only alternative I've found is throwing away the automatic usage message and writing a custom one. Even if I want to do that, it's not clear how to specify that while using argh, since it's a parameter to argparse's parser constructor rather than add_argument.

Activity

  1. neithere commented on Sep 20, 2024

    @neithere
    Owner

    Hi @mjreed-wbd, thank you for the report!

    Do I understand correctly that you have a code similar to this:

    def command(release_the_nuclear_weapons=False): ...
    

    and would like the help to look like this:

    $ my-app -h
    usage: my-app [-h] [--release-the-nuclear-weapons]
    
    options:
      -h, --help                           show this help message and exit
      -r, --release-the-nuclear-weapons    False
    

    ...while in fact it looks as follows?

    $ my-app -h
    usage: my-app [-h] [-r]
    
    options:
      -h, --help                           show this help message and exit
      -r, --release-the-nuclear-weapons    False
    

    As far as I understand, argparse chooses the short version over the long one, so there's no way to affect this from argh apart from disabling the automatic creation of the short version. At the moment it's not possible to disable it. I wonder if that would be a solution to your problem at all: would you prefer to enable only long names as long as they are displayed in the short usage text?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions