Skip to content

Fix: --help option#665

Merged
straight-shoota merged 6 commits intomasterfrom
fix/help-options
Jan 21, 2025
Merged

Fix: --help option#665
straight-shoota merged 6 commits intomasterfrom
fix/help-options

Conversation

@ysbaddaden
Copy link
Contributor

Restores the behavior where --help would always skip the command to be invoked, while still allowing to pass the --help to external subcommands:

The following commands print the help message and exit:

  • shards --help
  • shards --local --help
  • shards update --help

While the following tries to call shards-unknown --help then falls back to print the help message and exit:

  • shards unknown --help

Relies on a fixed list of the builtin command names to avoid having each when case starting with display_help_and_exit(opts) if display_help.

closes #649

The --help option would invoke the command then print the help message,
instead of skipping the command. For example `shards update --help`
would run the update command then print the help message.

Since shards default to the install command when none is provided, it
led "shards --help" to always run the install command then print the
help.

This patch fixes this issue while still allowing to pass --help to
external `shard-[command]` subcommands.
@ysbaddaden ysbaddaden added this to the 0.19.1 milestone Jan 20, 2025
@ysbaddaden ysbaddaden self-assigned this Jan 20, 2025
@straight-shoota
Copy link
Member

I'm not sure if the hard coded list is worth it. Ideally, every command should have its own help message. So the currently duplicated display_help_and_exit(opts) if display_help is just a temporary stand-in because we don't have specific messages. Eventually, it might become something like display_help_for_install_and_exit(opts) if display_help etc.

@straight-shoota straight-shoota merged commit b72eacf into master Jan 21, 2025
17 checks passed
@straight-shoota straight-shoota deleted the fix/help-options branch January 21, 2025 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shards --help invokes install subcommand

2 participants