Visitar URL original
fix(complete): show help for short flag completions by Ehsan-hash · Pull Request #1561 · jdx/usage · GitHub
Skip to content

fix(complete): show help for short flag completions - #1561

Merged
jdx merged 4 commits into
jdx:mainfrom
Ehsan-hash:fix/short-flag-completion-help
Oct 16, 2026
Merged

jdx merged 4 commits into
jdx:mainfrom
Ehsan-hash:fix/short-flag-completion-help

Conversation

@Ehsan-hash

@Ehsan-hash Ehsan-hash commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Short options now show their flag's existing help text in completion menus, just like long options. For flag "-v --verbose" help="Verbose output", completing -v previously returned an empty description; it now returns Verbose output.

Short spellings resolve through the parser's flag map, so an inherited and local flag that share -q cannot give it the wrong description. The change preserves hidden aliases, prefix filtering, sorting and name-based deduplication. Bash continues to receive values only. Regressions exercise the actual CLI, including described aliases, hidden flags, flags without help and colliding short spellings.

Validation: 66 completion tests, formatting and CLI/tests Clippy pass. Original and patched binaries were compared across all five CLI output formats and through the generated Zsh handler. The short-spelling collision was reproduced on the first submitted version and corrected. The shell integration harness has the same 31 pass / 3 fail result on the original and final binaries: two failures require a newer Bash than macOS's Bash 3, and the existing generic Zsh interactive test times out. Missing Fish, PowerShell, Nu and bash-completion coverage was not treated as executed shell coverage. Independent read-only review covers the complete updated candidate.

AI-assisted — Tool: Codex; model: OpenAI/gpt-6.1-sol (conductor), OpenAI/gpt-5.6-luna (implementation), OpenAI/gpt-5.6-sol (review); version: codex-cli 0.162.1.

Summary by CodeRabbit

  • Bug Fixes
    • Flag suggestions in fish shell completion now show help text for short aliases, matching their long aliases. Short flags without help remain undescribed, and hidden flags are omitted. When a short flag is shared across the root command and a subcommand, suggestions now reflect the correct flag ownership and help text while preserving applicable value completions.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T15:33:36.273276Z 1172b9e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Central YAML (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4d54a366-d5a7-400d-bc9e-0318ebac2d9d
📥 Commits

Reviewing files that changed from the base of the PR and between ef584f4 and 1172b9e.

📒 Files selected for processing: 2
  • cli/src/cli/complete_word.rs
  • cli/tests/complete_word.rs

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

Short-flag completion now resolves each unique short name to its owning flag. It omits hidden owners and aliases, and includes the owner’s help text in the completion candidate. Tests cover hidden flags, missing help text, and duplicate short-flag ownership across root and subcommand scopes.

Changes: Short flag completion

Layer / File(s) Summary
Short flag help and completion output
cli/src/cli/complete_word.rs, cli/tests/complete_word.rs
Short-flag completion resolves each unique short name to its owner, omits hidden owners and aliases, and uses the owner’s help text. Tests check completion descriptions and duplicate short-flag ownership across root and subcommand scopes.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: jdx

Merge Risk: ⚪ Minimal · up to 1172b

No actionable merge-blocking issue was established for short-flag completion help. The change is ready to merge after normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Docstring Coverage Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: showing help text for short flag completions.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Short flag completions now show their flag’s help text.

  • Short flag suggestions show their flag's help text.

Reviews (2) · Last reviewed commit: "fix(complete): use the parsed owner for ..." · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ef584f4d2b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cli/src/cli/complete_word.rs Outdated
f.short
.iter()
.filter(|short| !f.hidden_short_aliases.contains(short))
.map(|short| (*short, f.help.clone().unwrap_or_default()))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Resolve short help through the short-key owner

flags.values() still includes a flag under its long key when merge_subcommand_flags in lib/src/parse.rs assigns its colliding short key to another flag, so attaching help before unique_by makes lexicographic map order choose the description. For example, with an inherited global -q --zeta and a local -q --alpha, parsing keeps the global as the -q owner, but --alpha sorts first and completion now labels -q with the local flag's help; resolve the short spelling through its actual map entry before selecting the help text.

Useful? React with 👍 / 👎.

@Ehsan-hash

Copy link
Copy Markdown
Contributor Author

Fixed the short-key ownership finding in 1172b9e. Completion now gets visibility and help from the same short-key owner used by parsing. The regression reproduces the incorrect local description on the first submitted head and verifies the inherited global description and value completion after the repair. All 66 completion tests, formatting, affected Clippy and fresh independent review pass; the broader shell harness retains only the same three original-binary failures disclosed above.

@codex review

AI-assisted — Tool: Codex; model: OpenAI/gpt-6.1-sol; version: codex-cli 0.162.1.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1172b9ed10

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jdx
jdx merged commit 7a92e42 into jdx:main Oct 16, 2026
13 checks passed
mise-en-dev added a commit that referenced this pull request Oct 17, 2026
<!-- entire-trail-link-start -->
https://entire.io/gh/jdx/usage/trails/98
<!-- entire-trail-link-end -->

### 🐛 Bug Fixes

- **(complete)** read .<script>.usage.kdl sidecar when completing
scripts by [@jdx](https://github.com/jdx) in
[#1558](#1558)
- **(complete)** show help for short flag completions by
[@Ehsan-hash](https://github.com/Ehsan-hash) in
[#1561](#1561)

### 🛡️ Security

- replace prettier with oxfmt by [@jdx](https://github.com/jdx) in
[#1560](#1560)

### 🔍 Other Changes

- **(release)** shorten minimum release age to 2 days by
[@jdx](https://github.com/jdx) in
[52b1b78](52b1b78)
- pin perf-runner image by tag and stop automerging it by
[@jdx](https://github.com/jdx) in
[#1562](#1562)

### New Contributors

- @Ehsan-hash made their first contribution in
[#1561](#1561)

Copy link
Copy Markdown
Contributor Author

Thanks for merging this, @jdx!

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.

2 participants