feat: Print help menu on --help
for all commands
#1456
+297
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Uses a function
has_help_flag
to determine if should print the help menu. If it should, it prints all valid uses (fromhelp.txt
), and returns success.These changes also change some invocations of
printf
todisplay_error
(of some help text), since in other places it was used and it is more correct. These changes are only in places where no argument were passed, and the help menu is printed while exiting with code1
.Fixes: #1330
Other Information
I saw that the
asdf shell
help commands were different.In
help.txt
:In
command-export-shell-version.bash
:I assume one of them should be updated?
More generally, I think there is an issue that the help menu and its shorthands with
--help
can be out of sync. Should I do some restructuring so that instead ofcat
ing thehelp.txt
file, it uses a shared variables approach? (see the hack I do for so alignment works for both the source and the output):Another approach is something I've done, where various functions with multiple
printf
s are called in sequence, but that is more for a help menu that looks completely differentdifferent help menu
Or, we can just leave the changes as they are - thoughts?