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 option to not print help if no arguments are given #3

Merged
merged 4 commits into from
Jul 31, 2023

Conversation

MiroPalmu
Copy link

Let's say we have program foo which parses command line options with:

argz::parse(about, opts, argc, argv);

and it is run with

./foo

help message is printed due to check in argz.hpp:138

This PR adds new parse function that does not print help if there is no options:

argz::parse_when_no_options_is_possible(about, opts, argc, argv);

So now ./foo will not print help.

parse_when_no_options_is_possible is bad name and could be improved.

Miro Palmu added 2 commits July 29, 2023 18:13
When calling new parsing function:

	parse_when_no_options_is_possible

with no options (argc is 1) does not print help

Should not break any usage of library.
@MiroPalmu MiroPalmu changed the title Add option to print help if no arguments are given Add option to not print help if no arguments are given Jul 29, 2023
@stephenberry
Copy link
Owner

@MiroPalmu
So, I think this is a great feature, but I'd rather just always call the same parse function in all cases. So, I added print_help_when_no_options to the about struct, which provides an easy way to add this behavior. Do you have any concerns with this?

@stephenberry
Copy link
Owner

I'm just merging this with my change, but let me know if you'd prefer a different solution.

@stephenberry stephenberry merged commit 8a82dad into stephenberry:main Jul 31, 2023
3 checks passed
@MiroPalmu
Copy link
Author

Oh that is much cleaner thanks!

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

Successfully merging this pull request may close these issues.

2 participants