Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

feat(init): Add --source to Fish global optspecs

Maximilian Roos36c0c0e8c102
diff --git a/src/commands/init.rs b/src/commands/init.rs
index c4d6df1f6..08f8466d9 100644
--- a/src/commands/init.rs
+++ b/src/commands/init.rs
@@ -68,6 +68,20 @@ pub fn handle_init(shell: shell::Shell, cli_cmd: &mut Command) -> Result<(), Str
line.to_string()
};
+ // For Fish: Add --source to global optspecs so argparse recognizes it
+ // --source is shell-wrapper-only but Fish's argparse needs to know about it
+ // for completion to work when users type "wt --source <TAB>"
+ let line = if matches!(shell, shell::Shell::Fish)
+ && line.contains("string join \\n v/verbose internal")
+ {
+ line.replace(
+ "string join \\n v/verbose internal",
+ "string join \\n source v/verbose internal",
+ )
+ } else {
+ line
+ };
+
println!("{}", line);
}
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index 6f9e07192..de54ad433 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -12,10 +12,11 @@ info:
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: /dev/null
GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmp0566RD/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpZyxEdr/test-config.toml
---
success: true
exit_code: 0
@@ -172,7 +173,7 @@ end
# Static completions (commands and flags)
# Print an optspec for argparse to handle cmd's options that are independent of any subcommand.
function __fish_wt_global_optspecs
- string join \n v/verbose internal h/help V/version
+ string join \n source v/verbose internal h/help V/version
end
function __fish_wt_needs_command