Skip to content

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

fix: Display command path correctly in help output

Maximilian Roos0820e5221b9d
diff --git a/src/cli.rs b/src/cli.rs
index 3f9e37adb..0a5978b7c 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -66,20 +66,21 @@ Options:
/// Build a clap Command for Cli with the shared help template applied recursively.
pub fn build_command() -> Command {
let cmd = Cli::command();
- apply_help_template_recursive(cmd)
+ apply_help_template_recursive(cmd, DEFAULT_COMMAND_NAME)
}
-fn apply_help_template_recursive(mut cmd: Command) -> Command {
+fn apply_help_template_recursive(mut cmd: Command, path: &str) -> Command {
let template = if cmd.get_subcommands().next().is_some() {
HELP_TEMPLATE_WITH_SUBCOMMANDS
} else {
HELP_TEMPLATE
};
- cmd = cmd.help_template(template);
+ cmd = cmd.help_template(template).display_name(path);
for sub in cmd.get_subcommands_mut() {
let sub_cmd = std::mem::take(sub);
- let sub_cmd = apply_help_template_recursive(sub_cmd);
+ let sub_path = format!("{} {}", path, sub_cmd.get_name());
+ let sub_cmd = apply_help_template_recursive(sub_cmd, &sub_path);
*sub = sub_cmd;
}
cmd
diff --git a/tests/snapshots/integration__integration_tests__help__help_beta.snap b/tests/snapshots/integration__integration_tests__help__help_beta.snap
index c6b6cd89c..b7dc65a54 100644
--- a/tests/snapshots/integration__integration_tests__help__help_beta.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_beta.snap
@@ -13,7 +13,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt-beta - Development and testing utilities
+wt beta - Development and testing utilities
Usage: wt beta [OPTIONS] <COMMAND>
Commands:
diff --git a/tests/snapshots/integration__integration_tests__help__help_config.snap b/tests/snapshots/integration__integration_tests__help__help_config.snap
index 3965576a9..d286ceb61 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config.snap
@@ -13,7 +13,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt-config - Manage configuration and shell integration
+wt config - Manage configuration and shell integration
Usage: wt config [OPTIONS] <COMMAND>
Commands:
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_shell.snap b/tests/snapshots/integration__integration_tests__help__help_config_shell.snap
index 1757fca20..d0e6f7fb1 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_shell.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_shell.snap
@@ -14,7 +14,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt-config-shell - Shell integration setup
+wt config shell - Shell integration setup
Usage: wt config shell [OPTIONS] <COMMAND>
Commands:
diff --git a/tests/snapshots/integration__integration_tests__help__help_list.snap b/tests/snapshots/integration__integration_tests__help__help_list.snap
index 76e9047b5..25d231379 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list.snap
@@ -13,7 +13,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt-list - List worktrees and optionally branches
+wt list - List worktrees and optionally branches
Usage: wt list [OPTIONS]
Options:
diff --git a/tests/snapshots/integration__integration_tests__help__help_merge.snap b/tests/snapshots/integration__integration_tests__help__help_merge.snap
index d338485c4..e34ba194e 100644
--- a/tests/snapshots/integration__integration_tests__help__help_merge.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_merge.snap
@@ -13,7 +13,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt-merge - Merge worktree into target branch
+wt merge - Merge worktree into target branch
Usage: wt merge [OPTIONS] [TARGET]
Options:
diff --git a/tests/snapshots/integration__integration_tests__help__help_remove.snap b/tests/snapshots/integration__integration_tests__help__help_remove.snap
index 70b8bcebd..c6b7dbc6e 100644
--- a/tests/snapshots/integration__integration_tests__help__help_remove.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_remove.snap
@@ -13,7 +13,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt-remove - Remove worktree and branch
+wt remove - Remove worktree and branch
Usage: wt remove [OPTIONS] [WORKTREES]...
Options:
diff --git a/tests/snapshots/integration__integration_tests__help__help_switch.snap b/tests/snapshots/integration__integration_tests__help__help_switch.snap
index 3a1308bed..a3649c222 100644
--- a/tests/snapshots/integration__integration_tests__help__help_switch.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_switch.snap
@@ -13,7 +13,7 @@ info:
success: true
exit_code: 0
----- stdout -----
-wt-switch - Switch to a worktree
+wt switch - Switch to a worktree
Usage: wt switch [OPTIONS] <BRANCH>
Options: