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

feat: Print help menu on --help for all commands #1456

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hyperupcall
Copy link
Contributor

@hyperupcall hyperupcall commented Jan 25, 2023

Summary

Uses a function has_help_flag to determine if should print the help menu. If it should, it prints all valid uses (from help.txt), and returns success.

These changes also change some invocations of printf to display_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 code 1.

Fixes: #1330

Other Information

I saw that the asdf shell help commands were different.

In help.txt:

asdf shell <name> <version>

In command-export-shell-version.bash:

asdf shell <name> {<version>|--unset}

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 of cating the help.txt file, it uses a shared variables approach? (see the hack I do for so alignment works for both the source and the output):

asdf_help() {
  ...
  printf '%s\n' "MANAGE PLUGINS
${asdf_help_plugin_add:          }      Add a plugin from the plugin repo OR,
                                        add a Git repo as a plugin by
                                        specifying the name and repo url
${adsf_help_plugin_list1:        }      List installed plugins. Optionally show"

Another approach is something I've done, where various functions with multiple printfs are called in sequence, but that is more for a help menu that looks completely different

different help menu
Usage:
    command [flags] <command> [--help] [args...]

Flags:
    -h, --help
        Print help

    -q, --quiet
        Do not log informative messages to stdout. Error messages will still be printed

Subcommand(s):
    init [--no-cd] <shell>
        Print code for a particular shell to set the proper PATH, etc.

    install [--no-cache] [--force] [name] [version]
        Install a particular tool
    ...

Or, we can just leave the changes as they are - thoughts?

@hyperupcall hyperupcall marked this pull request as ready for review January 29, 2023 01:32
@hyperupcall hyperupcall requested a review from a team as a code owner January 29, 2023 01:32
@jthegedus
Copy link
Contributor

I have been thinking about making a change like this for some time, so have some thoughts to share, but won't have the time to go through this issue thoroughly and share my thoughts for a few days.

@hyperupcall
Copy link
Contributor Author

hyperupcall commented Sep 17, 2023

@jthegedus Wondering if you are available to take a look at this now? (P.S. thank you for merging the other PRs)

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.

More CLI help menus
2 participants