Skip to content

fix: restore --help on every subcommand - #15

Merged
ColeMei merged 1 commit into
mainfrom
fix/subcommand-help
Aug 18, 2026
Merged

fix: restore --help on every subcommand#15
ColeMei merged 1 commit into
mainfrom
fix/subcommand-help

Conversation

@ColeMei

@ColeMei ColeMei commented Aug 18, 2026

Copy link
Copy Markdown
Owner

openwith set --help, openwith history --help — and the same for every other subcommand, with -h too — failed with error: unexpected argument '--help' found (exit 2).

Cause

disable_help_flag = true on the root Cli propagates to every subcommand in clap v4. The manual field beneath it put -h/--help back only at the root:

#[arg(short = 'h', long = "help", action = clap::ArgAction::HelpLong)]
pub help: (),

So subcommands had the flag disabled with nothing restoring it. openwith --help kept rendering the logo screen the whole time, which is why this survived since the custom help template was introduced.

Fix

Drop disable_help_flag and the manual field, and set the logo help_template on the root command only. Subcommands fall back to clap's generated help, which lists their real flags:

Usage: openwith history [OPTIONS]

Options:
  -n, --limit <LIMIT>  Maximum number of events to show [default: 20]
  -d, --days <DAYS>    Only show events from the last N days [default: 7]
      --all            Show every retained event, ignoring --days
      --json           Print JSON

disable_version_flag and its manual field stay — --version belongs to the root alone and was never affected.

Verified

  • Root --help and -h still render the ASCII-logo template
  • --version / -v unchanged
  • All 9 subcommands accept both --help and -h
  • openwith help <sub> works as well
  • completions (zsh/bash/fish) and mangen still produce output — the Homebrew formula calls both during install
  • Normal operation (current, history) unaffected

Two tests added. every_subcommand_accepts_help is 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.

`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.
@ColeMei
ColeMei merged commit 9285825 into main Aug 18, 2026
2 checks passed
@ColeMei
ColeMei deleted the fix/subcommand-help branch August 18, 2026 09:43
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.

1 participant