Skip to content

fix(nushell): use caret for invoking cmd in completion script#638

Merged
jdx merged 1 commit into
jdx:mainfrom
silvanshade:fix/nushell-caret
May 17, 2026
Merged

fix(nushell): use caret for invoking cmd in completion script#638
jdx merged 1 commit into
jdx:mainfrom
silvanshade:fix/nushell-caret

Conversation

@silvanshade
Copy link
Copy Markdown
Contributor

This PR modifies the nushell completion script to use caret for invoking commands. This fixes the following issue.

Issue

The generated nushell completion script does not use caret for invoking external commands which causes the shell to interpret {usage_cmd} as a nushell function, producing an error.

Steps to reproduce

  1. Add the following to ~/.config/nushell/config.nu:
 ^aube completion nu | save --force ($nu.data-dir | path join "vendor/autoload/aube.nu")
  1. Load nushell and observe the error:
Error: nu::parser::extra_positional

  × Extra positional argument.
   ╭─[/Users/silvanshade/.local/share/nushell/vendor/autoload/aube.nu:6:18]
 5 │         if not ($spec_file | path exists) {
 6 │             aube usage | collect | save $spec_file
   ·                  ──┬──
   ·                    ╰── extra positional argument
 7 │         }
   ╰────
  help: Usage: aube

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 16, 2026

Greptile Summary

This PR fixes an issue in the generated nushell completion script where external commands were being invoked without the ^ sigil, causing nushell to interpret them as built-in functions and raising a parse error.

  • Adds ^ before {usage_cmd} and {usage_bin} at all three invocation sites in lib/src/complete/nu.rs, matching nushell's required syntax for external command execution.
  • Updates the three insta snapshot files to reflect the new generated output.

Confidence Score: 5/5

Safe to merge — the change is a minimal, targeted fix that correctly adds the nushell external-command sigil at every affected call site.

All three invocation sites in the generator and all three corresponding snapshot files are consistently updated. The fix aligns with documented nushell behavior and the snapshots confirm the tests will pass.

No files require special attention.

Important Files Changed

Filename Overview
lib/src/complete/nu.rs Adds ^ prefix to all three external command invocations; change is minimal, correct, and complete.
lib/src/complete/snapshots/usage__complete__nu__tests__complete_nu.snap Snapshot updated to reflect ^ prefix on both usage_cmd and usage_bin invocations.
lib/src/complete/snapshots/usage__complete__nu__tests__complete_nu-2.snap Snapshot updated to reflect ^ prefix on cache-key path's usage_cmd and usage_bin invocations.
lib/src/complete/snapshots/usage__complete__nu__tests__complete_nu-3.snap Snapshot updated to reflect ^ prefix on usage_bin invocation in the spec-based path.

Reviews (3): Last reviewed commit: "fix(nushell): use caret for invoking cmd..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Nushell completion logic in lib/src/complete/nu.rs by prefixing external command calls with a caret (^) to ensure the external binary is executed directly, bypassing any potential Nushell aliases or built-ins. I have no feedback to provide as there were no review comments to evaluate.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.34%. Comparing base (cd0fd34) to head (04c8673).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #638   +/-   ##
=======================================
  Coverage   75.34%   75.34%           
=======================================
  Files          49       49           
  Lines        7389     7389           
  Branches     7389     7389           
=======================================
  Hits         5567     5567           
  Misses       1217     1217           
  Partials      605      605           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jdx jdx merged commit 09c4564 into jdx:main May 17, 2026
6 checks passed
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