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

Add ability to display long options in usage message #231

Open
mjreed-wbd opened this issue Jul 25, 2024 · 1 comment
Open

Add ability to display long options in usage message #231

mjreed-wbd opened this issue Jul 25, 2024 · 1 comment
Assignees

Comments

@mjreed-wbd
Copy link

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.

@neithere
Copy link
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
Projects
None yet
Development

No branches or pull requests

2 participants