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

Offer ability to short circuit help output (Ex: -h) #30

Closed
Boscop opened this issue Jun 28, 2020 · 6 comments · Fixed by #106 · May be fixed by #53
Closed

Offer ability to short circuit help output (Ex: -h) #30

Boscop opened this issue Jun 28, 2020 · 6 comments · Fixed by #106 · May be fixed by #53
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Boscop
Copy link

Boscop commented Jun 28, 2020

Currently, passing -h doesn't work:

Unrecognized argument: -h

Passing -h should work the same as --help, unless one of the options/switches uses short = 'h'.


And in the Usage output, it would then show

-h, --help display usage information

instead of just

--help display usage information

@Boscop
Copy link
Author

Boscop commented Jul 3, 2020

Alternatively, to let the programmer decide (because maybe they want to use -h for something else),
there should be a way to manually call the function that prints the usage information (that's called when --help is passed).
So that it can be manually called when -h is passed with an explicit #[argh(switch, short = 'h')] help: bool field.

I.e. this function:

pub(crate) fn help(

But wrapped in a nicer way, callable as a method on the struct that FromArgs is derived on.

@benbrittain
Copy link
Contributor

I'd be far more amicable to that change! That seems like a good option for those that want -h support

@benbrittain benbrittain added bug Something isn't working good first issue Good for newcomers labels Jul 10, 2020
@benbrittain benbrittain changed the title Arg -h should work the same as --help Offer ability to short circuit help output Jul 10, 2020
@benbrittain benbrittain changed the title Offer ability to short circuit help output Offer ability to short circuit help output (Ex: -h) Jul 10, 2020
@msrd0
Copy link

msrd0 commented Aug 25, 2020

I'd also like to see an -h shorthand flag, and I'd be willing to create a PR. However, I am concerned that letting the user implement the shorthand and argh worry about the long flag, the help would end up looking something like that:

Options:
  -h                display usage information
  --help            display usage information

Therefore, I think either the user should be given the option to specify a shorthand for the help message, or be able to "replace" the help switch altogether. Let me know what you think.

@benbrittain
Copy link
Contributor

oh interesting, yes that makes sense. I'm open to a change like that!

@icefoxen
Copy link

Agreed on the -h shorthand flag. As for anything else, I don't want programmers to decide that -h should mean anything else, I want it to just be always a shorthand for --help.

@aminya
Copy link
Contributor

aminya commented Sep 1, 2021

I made a pull request that fixes this issue #106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
5 participants