fix: restore --help on every subcommand - #15
Merged
Merged
Conversation
`disable_help_flag` on the root Cli propagates to subcommands, and the manual -h/--help field put the flag back only at the root. Every `openwith <sub> --help` therefore failed with "unexpected argument", while `openwith --help` kept working — which is why it went unnoticed. Drop both and set the logo help_template on the root command only; subcommands fall back to clap's generated help, which lists their real flags. Adds a test that fails on the old definition.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
openwith set --help,openwith history --help— and the same for every other subcommand, with-htoo — failed witherror: unexpected argument '--help' found(exit 2).Cause
disable_help_flag = trueon the rootClipropagates to every subcommand in clap v4. The manual field beneath it put-h/--helpback only at the root:So subcommands had the flag disabled with nothing restoring it.
openwith --helpkept rendering the logo screen the whole time, which is why this survived since the custom help template was introduced.Fix
Drop
disable_help_flagand the manual field, and set the logohelp_templateon the root command only. Subcommands fall back to clap's generated help, which lists their real flags:disable_version_flagand its manual field stay —--versionbelongs to the root alone and was never affected.Verified
--helpand-hstill render the ASCII-logo template--version/-vunchanged--helpand-hopenwith help <sub>works as wellcompletions(zsh/bash/fish) andmangenstill produce output — the Homebrew formula calls both during installcurrent,history) unaffectedTwo tests added.
every_subcommand_accepts_helpis a genuine guard: it was confirmed to fail against the old definition (`openwith list` has no --help flag) and pass against the fix.Not tagging a release for this — it'll ride along with the next batch of changes.