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

Don't throw on positional errors if --help was passed #6

Closed
edannenberg opened this issue Feb 20, 2017 · 8 comments
Closed

Don't throw on positional errors if --help was passed #6

edannenberg opened this issue Feb 20, 2017 · 8 comments
Assignees
Milestone

Comments

@edannenberg
Copy link

When a script has required positionals it should not throw an error if the user also passed --help. The help is displayed but it prevents using a custom help function via ARG_OPTIONAL_ACTION([help]..), as die() always calls the default print_help. A user has to call ./foo.sh asd --help to see the custom help function.

Also ./foo.sh --help ending with FATAL ERROR: .... is probably not the best user experience.

@matejak
Copy link
Owner

matejak commented Apr 6, 2017

I think that I don't understand the entire issue, so please be patient with me :-)

  • I agree that it should be possible to somehow override the default help function. The question is how to do it, which is usually coupled with the reason why one wants to override default help. So could you please elaborate on that?
    Allowing help function written from scratch seems to be easy, but I have a feeling that you may like some of the stuff that Argbash does for you, but maybe you would like to leave something out or add something in?
  • I think that if you have an action argument, the script is supposed to end after the action is performed (however, the return code may vary, although the currently there is exit 0executed after the command). So the code that checks actual arguments passed before the declaration is not reached.
    Therefore, I don't understand how an error that you describe could possibly occur (so if it does, could you please attach a template that behaves like this?)

@matejak
Copy link
Owner

matejak commented Apr 6, 2017

I see that you actually elaborate on this in #3, so disregard the answer above for the time being, I have to get through #3 first.

@matejak
Copy link
Owner

matejak commented Apr 7, 2017

This is supposed to come with argbash-diy mode, where argbash will define functions for everything. Then, the script writer may decide to override or not to call some of them.

@edannenberg
Copy link
Author

👍 but the main point of this issue is unrelated to customization:

Also ./foo.sh --help ending with FATAL ERROR: .... is probably not the best user experience.

If the script foo.sh requires a positional arg, passing --help should not trigger the input validation at all IMO. --help is essentially a global command that should override everything, just display the help as requested and exit 0. Maybe nitpicking as the help is currently displayed, I wouldn't expect the error message though when running foo.sh --help.

@matejak
Copy link
Owner

matejak commented Apr 10, 2017

This is a matter of taste. I want to avoid a special case that would depend on argument name. My goal include making your setup possible without having to pass the argbash-generated output to additional scripts, but using other means than handling the --help argument in a special way.

@edannenberg
Copy link
Author

Fair points, I think this can be closed then unless you want to keep it open for reference.

@matejak matejak self-assigned this Apr 20, 2017
@matejak
Copy link
Owner

matejak commented Apr 20, 2017

This will be closed only when the issue is solved ;-) One bugfix release is to be expected before this is addressed.

@matejak matejak added this to the 2.5.0 milestone Aug 7, 2017
@matejak
Copy link
Owner

matejak commented Oct 30, 2017

Check out the DIY mode, it gives you what you need.

@matejak matejak closed this as completed Oct 30, 2017
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