-
Notifications
You must be signed in to change notification settings - Fork 15
fix(completions): ignore aliases and functions named usage (2nd attempt) #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(completions): ignore aliases and functions named usage (2nd attempt) #304
Conversation
…usage" (…" This reverts commit a5ed8bb.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #304 +/- ##
=======================================
Coverage 63.23% 63.23%
=======================================
Files 42 42
Lines 3454 3454
Branches 3454 3454
=======================================
Hits 2184 2184
Misses 982 982
Partials 288 288 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
bugbot run |
cli/assets/completions/_usage
Outdated
@@ -15,7 +15,7 @@ _usage() { | |||
typeset -A opt_args | |||
local curcontext="$curcontext" spec cache_policy | |||
|
|||
if ! command -v usage &> /dev/null; then | |||
if ! type -P usage &> /dev/null; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like you need to redirect stdout not stderr for type -P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&>
will redirect both stdout and stderr, so it should be fine.
lib/src/complete/snapshots/usage__complete__zsh__tests__complete_zsh-2.snap
Outdated
Show resolved
Hide resolved
I confirmed
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes shell completion scripts to properly ignore aliases and functions named "usage" when checking for the usage CLI tool's existence. The change replaces command -v
with type -p
for existence checks and prefixes direct usage calls with command
to bypass aliases/functions.
Key changes:
- Replace
command -v usage
withtype -p usage
for CLI existence checks - Prefix direct usage command calls with
command
to bypass aliases/functions - Update all affected shell completion files and test snapshots
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
lib/src/complete/zsh.rs | Updates zsh completion template to use type -p for checks and command usage for calls |
lib/src/complete/fish.rs | Updates fish completion template with same command resolution fixes |
lib/src/complete/bash.rs | Updates bash completion template with same command resolution fixes |
lib/bash-completion/bash_completion | Changes type -P to type -p for consistency |
cli/assets/completions/* | Updates static completion files for all shells |
lib/src/complete/snapshots/* | Updates test snapshots to reflect the template changes |
Reverts #301.
Replaces
command -v usage
withtype -P usage
to ignore aliases and functions.In the 1st attempt, I used
command usage
, but sinceusage
(orusage --help
) exits with an exit code2
, it didn't work as an existence check.I apologise for the trouble. Thank you for your help as always.