Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Add shell value_name to config shell subcommands
Maximilian Roosa3a340617f56
diff --git a/src/cli.rs b/src/cli.rsindex 51a535108..53b7c6004 100644--- a/src/cli.rs+++ b/src/cli.rs@@ -60,9 +60,43 @@ Usage: {usage}{all-args}{after-help}";+/// Cached value_name for Shell enum (e.g., "bash|fish|zsh|powershell")+///+/// TODO: There should be a simpler way to show ValueEnum variants in clap's "missing required+/// argument" error. Clap auto-generates `[possible values: ...]` in help and completions from+/// ValueEnum, but doesn't use it for value_name. We use mut_subcommand to set it dynamically,+/// but this feels overly complex. Revisit if clap adds better support.+fn shell_value_name() -> &'static str {+ static CACHE: OnceLock<String> = OnceLock::new();+ CACHE+ .get_or_init(|| {+ Shell::value_variants()+ .iter()+ .filter_map(|v| v.to_possible_value())+ .map(|v| v.get_name().to_owned())+ .collect::<Vec<_>>()+ .join("|")+ })+ .as_str()+}+/// Build a clap Command for Cli with the shared help template applied recursively.pub fn build_command() -> Command {- apply_help_template_recursive(Cli::command(), DEFAULT_COMMAND_NAME)+ let cmd = apply_help_template_recursive(Cli::command(), DEFAULT_COMMAND_NAME);++ // Set value_name for Shell args to show options in usage/errors+ let shell_name = shell_value_name();+ cmd.mut_subcommand("config", |c| {+ c.mut_subcommand("shell", |c| {+ c.mut_subcommand("init", |c| c.mut_arg("shell", |a| a.value_name(shell_name)))+ .mut_subcommand("install", |c| {+ c.mut_arg("shell", |a| a.value_name(shell_name))+ })+ .mut_subcommand("uninstall", |c| {+ c.mut_arg("shell", |a| a.value_name(shell_name))+ })+ })+ })}fn apply_help_template_recursive(mut cmd: Command, path: &str) -> Command {diff --git a/tests/integration_tests/init.rs b/tests/integration_tests/init.rsindex b641b53f0..37eb5e267 100644--- a/tests/integration_tests/init.rs+++ b/tests/integration_tests/init.rs@@ -68,7 +68,7 @@ fn test_init_invalid_shell(repo: TestRepo) {----- stdout ---------- stderr ------ [1m[31merror:[0m invalid value '[1m[33minvalid-shell[0m' for '[1m[36m<SHELL>[0m'+ [1m[31merror:[0m invalid value '[1m[33minvalid-shell[0m' for '[1m[36m<bash|fish|zsh|powershell>[0m'[possible values: [1m[32mbash[0m, [1m[32mfish[0m, [1m[32mzsh[0m, [1m[32mpowershell[0m]For more information, try '[1m[36m--help[0m'.