Skip to content

fix --help being skipped for bin routes that only partially resolve to a file - #6788

Merged
dhh merged 3 commits into
omacom:quattrofrom
EFrMG:bin-omarchy-h-flag
Aug 13, 2026
Merged

dhh merged 3 commits into
omacom:quattrofrom
EFrMG:bin-omarchy-h-flag

Conversation

@EFrMG

@EFrMG EFrMG commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Issue: #6787

Copilot AI balanced review requested due to automatic review settings August 13, 2026 05:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

dhh and others added 2 commits August 13, 2026 00:18
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
A `--` marks the rest of the args as belonging to the command itself, so
neither --help nor --json past it should be treated as router flags. The
--json check also matched substrings of flattened args, so a --json inside
one quoted argument switched --help output to JSON.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 13, 2026 07:31
@dhh

dhh commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Reviewed this against #6787 and pushed two fixup commits to the branch.

Verified

  • Reproduced the bug from the code: omarchy update aur --help resolves only as far as omarchy-update (prefix walk in resolve_direct_route), so aur --help was forwarded and a real update started. The same hole existed on the registered-route path — pre-fix, omarchy screenshot bogus --help would actually take a screenshot. The fix closes both (bin/omarchy:958, bin/omarchy:1022).
  • Exercised the matrix with hermetic fake binaries: full resolution, no-arg invocations, unknown routes (still exit 127 with suggestions), --help/-h mid-args and trailing, lookalike tokens (--helpme, -hx, a quoted "--help inside" all still forward), and --help --json. All behave.
  • Scanning the whole remainder is the right call here: internal scripts invoke the omarchy-* binaries directly, so the router is purely the human-facing surface, and a human typing --help anywhere on an omarchy line wants help. The direct binary remains the full-fidelity passthrough.

Pushed fixups (maintainerCanModify is on)

  1. 2676c3ad — two hardening tweaks to the same conditionals this PR touches:
    • Stop the help scan at -- (bin/omarchy:128): everything after -- belongs to the resolved command, so omarchy <cmd> run -- --help still forwards. That keeps a standard escape hatch for wrapper commands like update lock, launch tui, and hook that hand args to an inner program.
    • Match --json as an exact token via remaining_has_json_flag (bin/omarchy:139) instead of substring-matching " ${remaining[*]} ". The flattened-argv check meant a --json inside one quoted argument (e.g. omarchy agent prompt 'explain --json output' --help) flipped help output to JSON. Pre-existing, but this PR's broader help matching made it much easier to hit.
  2. ab23949c — regression tests in test/cli:761 using the suite's fake-binary pattern: partial resolution with trailing --help/-h renders help without executing (verified the test fails against the pre-PR router by actually running the fixture), same via an alias route (covers dispatch_or_help), related-commands listing, exact-argv forwarding when no help flag is present, -- passthrough, and both --json cases.

./test/cli: 116/116 passing. The one ./test/all failure (test/shell.d/config-test.sh, a PKGBUILD/systemd-service check) is unrelated and pre-existing — this diff only touches bin/omarchy and test/cli.

One known non-goal, matching the issue writeup: groups without a bare parent binary (e.g. omarchy theme bogus --help) still report "Unknown Omarchy command" rather than group help — nothing executes there, so it's cosmetic and fine to leave for a broader unknown-subcommand pass.

— 🤖 Claude, posting on behalf of @dhh

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 2 changed files in this pull request and generated no new comments.

@dhh
dhh merged commit 9672d85 into omacom:quattro Aug 13, 2026
nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
… to a file (omacom#6788)

* fix `--help` being skipped for bin routes that only partially resolve to a file

* Add regression tests for --help on partially resolved routes

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Stop help-flag scanning at -- and match --json as an exact token

A `--` marks the rest of the args as belonging to the command itself, so
neither --help nor --json past it should be treated as router flags. The
--json check also matched substrings of flattened args, so a --json inside
one quoted argument switched --help output to JSON.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

3 participants