Skip to content

Commit f4d6874

Browse files
0x4D5352claude
andauthored
Fix claude completion for optional-valued flags (#1288)
`--resume`, `--from-pr` and `--worktree` take an *optional* value in the Claude Code CLI (`-r, --resume [value]` in `claude --help`), but the extern declared them as `string` flags. A bare `claude --resume`, which is how you open the interactive session picker, therefore fails to parse: ``` Error: nu::parser::missing_flag_param x Missing flag argument. ``` Nushell flags can't have an optional value, so this declares the three as switches. An extern passes its arguments to the external command in the order they were typed, so a value after the switch still arrives where the CLI expects it: ``` claude --resume => [--resume] claude -r abc -p hi => [--resume][abc][--print][hi] claude -w feature => [--worktree][feature] claude --from-pr 123 => [--from-pr][123] claude --remote-control desk => [--remote-control][desk] ``` (argv as received by a stub `claude` on `PATH`.) The one thing lost is the `--resume=<id>` spelling, which Nushell reads as a boolean on a switch; `--resume <id>` works. Also: - adds `--remote-control`, which was missing and takes an optional name in the same way - refreshes the value lists against Claude Code 2.1.302: effort gains `xhigh` and `max`; permission-mode gains `auto` and `manual` and drops `default`, which the CLI no longer lists as a choice; models moves to the current aliases (`fable`, `opus`, `sonnet`, `haiku`) and model IDs Tested on Nushell 0.116.1: `toolkit.nu check pr` on the file passes, and `commandline complete` returns the new lists for `--effort`, `--permission-mode` and `--model`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 44f8f25 commit f4d6874

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎custom-completions/claude/claude-completions.nu‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ def "nu-complete claude input-format" [] {
1414
}
1515

1616
def "nu-complete claude permission-mode" [] {
17-
[acceptEdits bypassPermissions default dontAsk plan]
17+
[acceptEdits auto bypassPermissions manual dontAsk plan]
1818
}
1919

2020
def "nu-complete claude models" [] {
21-
[sonnet opus haiku claude-sonnet-4-6]
21+
[fable opus sonnet haiku claude-fable-5-1 claude-opus-5-5 claude-sonnet-5-5 claude-haiku-5-5]
2222
}
2323

2424
def "nu-complete claude effort" [] {
25-
[low medium high]
25+
[low medium high xhigh max]
2626
}
2727

2828
def "nu-complete claude scope" [] {
@@ -41,6 +41,12 @@ def "nu-complete claude install-channel" [] {
4141
[stable latest]
4242
}
4343

44+
# --resume, --from-pr, --worktree and --remote-control take an optional value,
45+
# which a Nushell flag cannot express, so they are declared as switches. A value
46+
# typed after one is passed to claude in place, as a positional:
47+
# `claude --resume` opens the session picker and `claude --resume <id>` resumes.
48+
# The `--flag=value` spelling is not available for these flags.
49+
4450
# Claude Code - starts an interactive session by default, use -p/--print for non-interactive output
4551
export extern claude [
4652
--debug(-d) # Enable debug mode
@@ -66,7 +72,7 @@ export extern claude [
6672
--append-system-prompt: string # Append system prompt
6773
--permission-mode: string@"nu-complete claude permission-mode" # Permission mode
6874
--continue(-c) # Continue last session
69-
--resume(-r): string # Resume session by ID
75+
--resume(-r) # Resume a session (optional ID or search term)
7076
--fork-session # Fork session
7177
--no-session-persistence # Disable session persistence
7278
--model: string@"nu-complete claude models" # Model to use
@@ -84,9 +90,10 @@ export extern claude [
8490
--disable-slash-commands # Disable slash commands
8591
--chrome # Enable Chrome
8692
--no-chrome # Disable Chrome
87-
--from-pr: string # From PR
93+
--from-pr # Resume a session linked to a PR (optional number or URL)
8894
--file: path # Input file
89-
--worktree(-w): string # Git worktree
95+
--worktree(-w) # Create a git worktree (optional name)
96+
--remote-control # Start with Remote Control enabled (optional name)
9097
--tmux # Tmux mode
9198
--effort: string@"nu-complete claude effort" # Effort level
9299
--version(-v) # Show version

0 commit comments

Comments
 (0)