Skip to content

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

refactor: Move approval commands to config namespace (#31)

Maximilian Roos839280510132
diff --git a/src/cli.rs b/src/cli.rs
index 411b8d7ab..3f9e37adb 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -197,6 +197,27 @@ Skip confirmation prompt:
},
}
+#[derive(Subcommand)]
+pub enum ApprovalsCommand {
+ /// Store approvals in config
+ Ask {
+ /// Skip approval prompts
+ #[arg(short, long)]
+ force: bool,
+
+ /// Show all commands
+ #[arg(long)]
+ all: bool,
+ },
+
+ /// Clear approved commands from config
+ Clear {
+ /// Clear global approvals
+ #[arg(short, long)]
+ global: bool,
+ },
+}
+
#[derive(Subcommand)]
pub enum ConfigCommand {
/// Shell integration setup
@@ -219,6 +240,12 @@ pub enum ConfigCommand {
#[command(subcommand)]
action: StatusAction,
},
+
+ /// Manage command approvals
+ Approvals {
+ #[command(subcommand)]
+ action: ApprovalsCommand,
+ },
}
#[derive(Subcommand)]
@@ -300,24 +327,6 @@ pub enum StandaloneCommand {
target: Option<String>,
},
- /// Store approvals in config
- AskApprovals {
- /// Skip approval prompts
- #[arg(short, long)]
- force: bool,
-
- /// Show all commands
- #[arg(long)]
- all: bool,
- },
-
- /// Clear approved commands from config
- ClearApprovals {
- /// Clear global approvals
- #[arg(short, long)]
- global: bool,
- },
-
/// Interactive worktree selector
///
/// Preview modes (toggle with 1/2/3):
diff --git a/src/main.rs b/src/main.rs
index 3fa98730a..46e28dede 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -32,7 +32,10 @@ use commands::{
};
use output::{execute_user_command, handle_remove_output, handle_switch_output};
-use cli::{Cli, Commands, ConfigCommand, ConfigShellCommand, StandaloneCommand, StatusAction};
+use cli::{
+ ApprovalsCommand, Cli, Commands, ConfigCommand, ConfigShellCommand, StandaloneCommand,
+ StatusAction,
+};
/// Try to handle --help flag with pager before clap processes it
fn maybe_handle_help_with_pager() -> bool {
@@ -252,6 +255,10 @@ fn main() {
StatusAction::Set { value, branch } => handle_config_status_set(value, branch),
StatusAction::Unset { target } => handle_config_status_unset(target),
},
+ ConfigCommand::Approvals { action } => match action {
+ ApprovalsCommand::Ask { force, all } => handle_standalone_ask_approvals(force, all),
+ ApprovalsCommand::Clear { global } => handle_standalone_clear_approvals(global),
+ },
},
Commands::Standalone { action } => match action {
StandaloneCommand::RunHook { hook_type, force } => {
@@ -268,12 +275,6 @@ fn main() {
allow_merge_commits,
} => handle_push(target.as_deref(), allow_merge_commits, "Pushed to", None),
StandaloneCommand::Rebase { target } => handle_rebase(target.as_deref()).map(|_| ()),
- StandaloneCommand::AskApprovals { force, all } => {
- handle_standalone_ask_approvals(force, all)
- }
- StandaloneCommand::ClearApprovals { global } => {
- handle_standalone_clear_approvals(global)
- }
#[cfg(unix)]
StandaloneCommand::Select => handle_select(),
},
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index e1d5e4e3f..1708563b1 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -103,6 +103,8 @@ pub struct TestRepo {
remote: Option<PathBuf>, // Path to bare remote repo if created
/// Isolated config file for this test (prevents pollution of user's config)
test_config_path: PathBuf,
+ /// Git config file with test settings (advice disabled, etc.)
+ git_config_path: PathBuf,
/// Path to mock bin directory for gh/glab commands
mock_bin_path: Option<PathBuf>,
}
@@ -122,12 +124,21 @@ impl TestRepo {
// Create isolated config path for this test
let test_config_path = temp_dir.path().join("test-config.toml");
+ // Create git config file with test settings
+ let git_config_path = temp_dir.path().join("test-gitconfig");
+ std::fs::write(
+ &git_config_path,
+ "[advice]\n\tmergeConflict = false\n\tresolveConflict = false\n",
+ )
+ .expect("Failed to write git config");
+
let repo = Self {
temp_dir,
root,
worktrees: HashMap::new(),
remote: None,
test_config_path,
+ git_config_path,
mock_bin_path: None,
};
@@ -162,7 +173,8 @@ impl TestRepo {
/// This sets environment variables only for the specific command,
/// ensuring thread-safety and test isolation.
pub fn configure_git_cmd(&self, cmd: &mut Command) {
- cmd.env("GIT_CONFIG_GLOBAL", "/dev/null");
+ // Use test git config file with advice settings disabled
+ cmd.env("GIT_CONFIG_GLOBAL", &self.git_config_path);
cmd.env("GIT_CONFIG_SYSTEM", "/dev/null");
cmd.env("GIT_AUTHOR_DATE", "2025-01-01T00:00:00Z");
cmd.env("GIT_COMMITTER_DATE", "2025-01-01T00:00:00Z");
@@ -170,10 +182,6 @@ impl TestRepo {
cmd.env("LANG", "C");
// Oct 28, 2025 - exactly 300 days (10 months) after commit date for deterministic relative times
cmd.env("SOURCE_DATE_EPOCH", "1761609600");
- // Disable git advice hints for stable output across versions
- cmd.env("GIT_CONFIG_COUNT", "1");
- cmd.env("GIT_CONFIG_KEY_0", "advice.mergeConflict");
- cmd.env("GIT_CONFIG_VALUE_0", "false");
}
/// Get standard test environment variables as a vector
@@ -184,7 +192,11 @@ impl TestRepo {
vec![
("CLICOLOR_FORCE".to_string(), "1".to_string()),
("COLUMNS".to_string(), "150".to_string()),
- ("GIT_CONFIG_GLOBAL".to_string(), "/dev/null".to_string()),
+ // Use test git config file with advice settings disabled
+ (
+ "GIT_CONFIG_GLOBAL".to_string(),
+ self.git_config_path.display().to_string(),
+ ),
("GIT_CONFIG_SYSTEM".to_string(), "/dev/null".to_string()),
(
"GIT_AUTHOR_DATE".to_string(),
@@ -197,13 +209,6 @@ impl TestRepo {
("LC_ALL".to_string(), "C".to_string()),
("LANG".to_string(), "C".to_string()),
("SOURCE_DATE_EPOCH".to_string(), "1761609600".to_string()),
- // Disable git advice hints for stable output across versions
- ("GIT_CONFIG_COUNT".to_string(), "1".to_string()),
- (
- "GIT_CONFIG_KEY_0".to_string(),
- "advice.mergeConflict".to_string(),
- ),
- ("GIT_CONFIG_VALUE_0".to_string(), "false".to_string()),
(
"WORKTRUNK_CONFIG_PATH".to_string(),
self.test_config_path().display().to_string(),
@@ -666,6 +671,9 @@ pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {
// (metadata is handled via redactions below)
settings.add_filter(r".*/\.tmp[^/]+/test-config\.toml", "[TEST_CONFIG]");
+ // Normalize GIT_CONFIG_GLOBAL temp paths
+ settings.add_filter(r".*/\.tmp[^/]+/test-gitconfig", "[TEST_GIT_CONFIG]");
+
// Normalize HOME temp directory in snapshots (stdout/stderr content)
// Matches any temp directory path (without trailing filename)
// Examples:
@@ -675,6 +683,7 @@ pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {
settings.add_filter(r"HOME: .*/\.tmp[^/\s]+", "HOME: [TEST_HOME]");
// Redact volatile metadata captured by insta-cmd (applies to the `info` block)
+ settings.add_redaction(".env.GIT_CONFIG_GLOBAL", "[TEST_GIT_CONFIG]");
settings.add_redaction(".env.WORKTRUNK_CONFIG_PATH", "[TEST_CONFIG]");
settings.add_redaction(".env.HOME", "[TEST_HOME]");
settings.add_redaction(".env.XDG_CONFIG_HOME", "[TEST_CONFIG_HOME]");
diff --git a/tests/integration_tests/approvals.rs b/tests/integration_tests/approvals.rs
index 3b1e117b5..809833505 100644
--- a/tests/integration_tests/approvals.rs
+++ b/tests/integration_tests/approvals.rs
@@ -8,8 +8,8 @@ use worktrunk::config::WorktrunkConfig;
fn snapshot_ask_approvals(test_name: &str, repo: &TestRepo, args: &[&str]) {
let settings = setup_snapshot_settings(repo);
settings.bind(|| {
- let mut cmd = make_snapshot_cmd(repo, "beta", &[], None);
- cmd.arg("ask-approvals").args(args);
+ let mut cmd = make_snapshot_cmd(repo, "config", &[], None);
+ cmd.arg("approvals").arg("ask").args(args);
assert_cmd_snapshot!(test_name, cmd);
});
}
@@ -18,8 +18,8 @@ fn snapshot_ask_approvals(test_name: &str, repo: &TestRepo, args: &[&str]) {
fn snapshot_clear_approvals(test_name: &str, repo: &TestRepo, args: &[&str]) {
let settings = setup_snapshot_settings(repo);
settings.bind(|| {
- let mut cmd = make_snapshot_cmd(repo, "beta", &[], None);
- cmd.arg("clear-approvals").args(args);
+ let mut cmd = make_snapshot_cmd(repo, "config", &[], None);
+ cmd.arg("approvals").arg("clear").args(args);
assert_cmd_snapshot!(test_name, cmd);
});
}
@@ -153,8 +153,8 @@ fn test_clear_approvals_after_clear() {
.expect("Failed to save approval");
// Clear approvals
- let mut cmd = make_snapshot_cmd(&repo, "beta", &[], None);
- cmd.arg("clear-approvals");
+ let mut cmd = make_snapshot_cmd(&repo, "config", &[], None);
+ cmd.arg("approvals").arg("clear");
cmd.output().expect("Failed to clear approvals");
// Try to clear again (should show "no approvals")
diff --git a/tests/snapshots/integration__integration_tests__help__help_beta.snap b/tests/snapshots/integration__integration_tests__help__help_beta.snap
index daa88e680..c6b6cd89c 100644
--- a/tests/snapshots/integration__integration_tests__help__help_beta.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_beta.snap
@@ -17,14 +17,12 @@ wt-beta - Development and testing utilities
Usage: wt beta [OPTIONS] <COMMAND>
Commands:
- run-hook Run project hook
- commit Commit changes with LLM-generated message
- squash Squash commits with LLM-generated message
- push Push changes to local target branch
- rebase Rebase onto target
- ask-approvals Store approvals in config
- clear-approvals Clear approved commands from config
- select Interactive worktree selector
+ run-hook Run project hook
+ commit Commit changes with LLM-generated message
+ squash Squash commits with LLM-generated message
+ push Push changes to local target branch
+ rebase Rebase onto target
+ select Interactive worktree selector
Options:
-C <path>
diff --git a/tests/snapshots/integration__integration_tests__help__help_config.snap b/tests/snapshots/integration__integration_tests__help__help_config.snap
index fed2e0ce2..3965576a9 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config.snap
@@ -22,6 +22,7 @@ Commands:
list List configuration files & locations
refresh-cache Refresh default branch from remote
status Manage branch status markers
+ approvals Manage command approvals
Options:
-C <path>
diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap
index 293f82eb1..82eda0893 100644
--- a/tests/snapshots/integration__integration_tests__init__init_bash.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap
@@ -12,16 +12,13 @@ info:
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
- GIT_CONFIG_COUNT: "1"
- GIT_CONFIG_GLOBAL: /dev/null
- GIT_CONFIG_KEY_0: advice.mergeConflict
+ GIT_CONFIG_GLOBAL: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpX880pk/test-gitconfig
GIT_CONFIG_SYSTEM: /dev/null
- GIT_CONFIG_VALUE_0: "false"
GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpcucFH7/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpX880pk/test-config.toml
---
success: true
exit_code: 0
@@ -203,12 +200,6 @@ _wt() {
wt,switch)
cmd="wt__switch"
;;
- wt__beta,ask-approvals)
- cmd="wt__beta__ask__approvals"
- ;;
- wt__beta,clear-approvals)
- cmd="wt__beta__clear__approvals"
- ;;
wt__beta,commit)
cmd="wt__beta__commit"
;;
@@ -227,6 +218,9 @@ _wt() {
wt__beta,squash)
cmd="wt__beta__squash"
;;
+ wt__config,approvals)
+ cmd="wt__config__approvals"
+ ;;
wt__config,create)
cmd="wt__config__create"
;;
@@ -242,6 +236,12 @@ _wt() {
wt__config,status)
cmd="wt__config__status"
;;
+ wt__config__approvals,ask)
+ cmd="wt__config__approvals__ask"
+ ;;
+ wt__config__approvals,clear)
+ cmd="wt__config__approvals__clear"
+ ;;
wt__config__shell,init)
cmd="wt__config__shell__init"
;;
@@ -283,7 +283,7 @@ _wt() {
return 0
;;
wt__beta)
- opts="-C -v -h --config --verbose --help run-hook commit squash push rebase ask-approvals clear-approvals select"
+ opts="-C -v -h --config --verbose --help run-hook commit squash push rebase select"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -304,8 +304,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__beta__ask__approvals)
- opts="-f -C -v -h --force --all --config --verbose --help"
+ wt__beta__commit)
+ opts="-f -C -v -h --force --no-verify --config --verbose --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -326,8 +326,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__beta__clear__approvals)
- opts="-g -C -v -h --global --config --verbose --help"
+ wt__beta__push)
+ opts="-C -v -h --allow-merge-commits --config --verbose --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -348,8 +348,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__beta__commit)
- opts="-f -C -v -h --force --no-verify --config --verbose --help"
+ wt__beta__rebase)
+ opts="-C -v -h --config --verbose --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -370,8 +370,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__beta__push)
- opts="-C -v -h --allow-merge-commits --config --verbose --help [TARGET]"
+ wt__beta__run__hook)
+ opts="-f -C -v -h --force --config --verbose --help post-create post-start pre-commit pre-merge post-merge"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -392,8 +392,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__beta__rebase)
- opts="-C -v -h --config --verbose --help [TARGET]"
+ wt__beta__select)
+ opts="-C -v -h --config --verbose --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -414,8 +414,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__beta__run__hook)
- opts="-f -C -v -h --force --config --verbose --help post-create post-start pre-commit pre-merge post-merge"
+ wt__beta__squash)
+ opts="-f -C -v -h --force --no-verify --config --verbose --help [TARGET]"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -436,9 +436,9 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__beta__select)
- opts="-C -v -h --config --verbose --help"
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
+ wt__config)
+ opts="-C -v -h --config --verbose --help shell create list refresh-cache status approvals"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
@@ -458,8 +458,8 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__beta__squash)
- opts="-f -C -v -h --force --no-verify --config --verbose --help [TARGET]"
+ wt__config__approvals)
+ opts="-C -v -h --config --verbose --help ask clear"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
@@ -480,9 +480,31 @@ _wt() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
- wt__config)
- opts="-C -v -h --config --verbose --help shell create list refresh-cache status"
- if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
+ wt__config__approvals__ask)
+ opts="-f -C -v -h --force --all --config --verbose --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ fi
+ case "${prev}" in
+ -C)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ --config)
+ COMPREPLY=($(compgen -f "${cur}"))
+ return 0
+ ;;
+ *)
+ COMPREPLY=()
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
+ return 0
+ ;;
+ wt__config__approvals__clear)
+ opts="-g -C -v -h --global --config --verbose --help"
+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
diff --git a/tests/snapshots/integration__integration_tests__init__init_fish.snap b/tests/snapshots/integration__integration_tests__init__init_fish.snap
index 49600c3ed..3ad73adcd 100644
--- a/tests/snapshots/integration__integration_tests__init__init_fish.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_fish.snap
@@ -12,16 +12,13 @@ info:
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
- GIT_CONFIG_COUNT: "1"
- GIT_CONFIG_GLOBAL: /dev/null
- GIT_CONFIG_KEY_0: advice.mergeConflict
+ GIT_CONFIG_GLOBAL: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpIGoCm6/test-gitconfig
GIT_CONFIG_SYSTEM: /dev/null
- GIT_CONFIG_VALUE_0: "false"
GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpmHNUsf/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpIGoCm6/test-config.toml
---
success: true
exit_code: 0
@@ -200,15 +197,16 @@ complete -c wt -n "__fish_wt_needs_command" -f -a "list" -d 'List worktrees and
complete -c wt -n "__fish_wt_needs_command" -f -a "switch" -d 'Switch to a worktree'
complete -c wt -n "__fish_wt_needs_command" -f -a "remove" -d 'Remove worktree and branch'
complete -c wt -n "__fish_wt_needs_command" -f -a "merge" -d 'Merge worktree into target branch'
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -s C -d 'Change working directory' -r -F
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -l config -d 'User config file path' -r -F
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -s v -l verbose -d 'Show commands and debug info'
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -s h -l help -d 'Print help (see more with \'--help\')'
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -f -a "shell" -d 'Shell integration setup'
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -f -a "create" -d 'Create global configuration file'
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -f -a "list" -d 'List configuration files & locations'
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -f -a "refresh-cache" -d 'Refresh default branch from remote'
-complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status" -f -a "status" -d 'Manage branch status markers'
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -s C -d 'Change working directory' -r -F
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -l config -d 'User config file path' -r -F
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -s v -l verbose -d 'Show commands and debug info'
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -s h -l help -d 'Print help (see more with \'--help\')'
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -f -a "shell" -d 'Shell integration setup'
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -f -a "create" -d 'Create global configuration file'
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -f -a "list" -d 'List configuration files & locations'
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -f -a "refresh-cache" -d 'Refresh default branch from remote'
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -f -a "status" -d 'Manage branch status markers'
+complete -c wt -n "__fish_wt_using_subcommand config; and not __fish_seen_subcommand_from shell create list refresh-cache status approvals" -f -a "approvals" -d 'Manage command approvals'
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from shell" -s C -d 'Change working directory' -r -F
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from shell" -l config -d 'User config file path' -r -F
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from shell" -s v -l verbose -d 'Show commands and debug info'
@@ -233,18 +231,22 @@ complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from status" -s h -l help -d 'Print help'
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from status" -f -a "set" -d 'Set status emoji for branch'
complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from status" -f -a "unset" -d 'Clear status emoji'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -s C -d 'Change working directory' -r -F
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -l config -d 'User config file path' -r -F
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -s v -l verbose -d 'Show commands and debug info'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -s h -l help -d 'Print help'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -f -a "run-hook" -d 'Run project hook'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -f -a "commit" -d 'Commit changes with LLM-generated message'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -f -a "squash" -d 'Squash commits with LLM-generated message'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -f -a "push" -d 'Push changes to local target branch'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -f -a "rebase" -d 'Rebase onto target'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -f -a "ask-approvals" -d 'Store approvals in config'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -f -a "clear-approvals" -d 'Clear approved commands from config'
-complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase ask-approvals clear-approvals select" -f -a "select" -d 'Interactive worktree selector'
+complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from approvals" -s C -d 'Change working directory' -r -F
+complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from approvals" -l config -d 'User config file path' -r -F
+complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from approvals" -s v -l verbose -d 'Show commands and debug info'
+complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from approvals" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from approvals" -f -a "ask" -d 'Store approvals in config'
+complete -c wt -n "__fish_wt_using_subcommand config; and __fish_seen_subcommand_from approvals" -f -a "clear" -d 'Clear approved commands from config'
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -s C -d 'Change working directory' -r -F
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -l config -d 'User config file path' -r -F
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -s v -l verbose -d 'Show commands and debug info'
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -s h -l help -d 'Print help'
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -f -a "run-hook" -d 'Run project hook'
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -f -a "commit" -d 'Commit changes with LLM-generated message'
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -f -a "squash" -d 'Squash commits with LLM-generated message'
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -f -a "push" -d 'Push changes to local target branch'
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -f -a "rebase" -d 'Rebase onto target'
+complete -c wt -n "__fish_wt_using_subcommand beta; and not __fish_seen_subcommand_from run-hook commit squash push rebase select" -f -a "select" -d 'Interactive worktree selector'
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from run-hook" -s C -d 'Change working directory' -r -F
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from run-hook" -l config -d 'User config file path' -r -F
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from run-hook" -s f -l force -d 'Skip approval prompts'
@@ -271,17 +273,6 @@ complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_f
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from rebase" -l config -d 'User config file path' -r -F
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from rebase" -s v -l verbose -d 'Show commands and debug info'
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from rebase" -s h -l help -d 'Print help'
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from ask-approvals" -s C -d 'Change working directory' -r -F
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from ask-approvals" -l config -d 'User config file path' -r -F
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from ask-approvals" -s f -l force -d 'Skip approval prompts'
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from ask-approvals" -l all -d 'Show all commands'
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from ask-approvals" -s v -l verbose -d 'Show commands and debug info'
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from ask-approvals" -s h -l help -d 'Print help'
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from clear-approvals" -s C -d 'Change working directory' -r -F
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from clear-approvals" -l config -d 'User config file path' -r -F
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from clear-approvals" -s g -l global -d 'Clear global approvals'
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from clear-approvals" -s v -l verbose -d 'Show commands and debug info'
-complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from clear-approvals" -s h -l help -d 'Print help'
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from select" -s C -d 'Change working directory' -r -F
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from select" -l config -d 'User config file path' -r -F
complete -c wt -n "__fish_wt_using_subcommand beta; and __fish_seen_subcommand_from select" -s v -l verbose -d 'Show commands and debug info'
diff --git a/tests/snapshots/integration__integration_tests__init__init_zsh.snap b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
index 96cacc0f1..1765b5beb 100644
--- a/tests/snapshots/integration__integration_tests__init__init_zsh.snap
+++ b/tests/snapshots/integration__integration_tests__init__init_zsh.snap
@@ -12,16 +12,13 @@ info:
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
- GIT_CONFIG_COUNT: "1"
- GIT_CONFIG_GLOBAL: /dev/null
- GIT_CONFIG_KEY_0: advice.mergeConflict
+ GIT_CONFIG_GLOBAL: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpWiQOW2/test-gitconfig
GIT_CONFIG_SYSTEM: /dev/null
- GIT_CONFIG_VALUE_0: "false"
GIT_EDITOR: ""
LANG: C
LC_ALL: C
SOURCE_DATE_EPOCH: "1761609600"
- WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpOTBJGU/test-config.toml
+ WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpWiQOW2/test-config.toml
---
success: true
exit_code: 0
@@ -343,6 +340,53 @@ _arguments "${_arguments_options[@]}" : \
esac
;;
esac
+;;
+(approvals)
+_arguments "${_arguments_options[@]}" : \
+'-C+[Change working directory]:path:_files' \
+'--config=[User config file path]:path:_files' \
+'-v[Show commands and debug info]' \
+'--verbose[Show commands and debug info]' \
+'-h[Print help]' \
+'--help[Print help]' \
+":: :_wt__config__approvals_commands" \
+"*::: :->approvals" \
+&& ret=0
+
+ case $state in
+ (approvals)
+ words=($line[1] "${words[@]}")
+ (( CURRENT += 1 ))
+ curcontext="${curcontext%:*:*}:wt-config-approvals-command-$line[1]:"
+ case $line[1] in
+ (ask)
+_arguments "${_arguments_options[@]}" : \
+'-C+[Change working directory]:path:_files' \
+'--config=[User config file path]:path:_files' \
+'-f[Skip approval prompts]' \
+'--force[Skip approval prompts]' \
+'--all[Show all commands]' \
+'-v[Show commands and debug info]' \
+'--verbose[Show commands and debug info]' \
+'-h[Print help]' \
+'--help[Print help]' \
+&& ret=0
+;;
+(clear)
+_arguments "${_arguments_options[@]}" : \
+'-C+[Change working directory]:path:_files' \
+'--config=[User config file path]:path:_files' \
+'-g[Clear global approvals]' \
+'--global[Clear global approvals]' \
+'-v[Show commands and debug info]' \
+'--verbose[Show commands and debug info]' \
+'-h[Print help]' \
+'--help[Print help]' \
+&& ret=0
+;;
+ esac
+ ;;
+esac
;;
esac
;;
@@ -429,31 +473,6 @@ _arguments "${_arguments_options[@]}" : \
'::target -- Target branch (defaults to default branch):_default' \
&& ret=0
;;
-(ask-approvals)
-_arguments "${_arguments_options[@]}" : \
-'-C+[Change working directory]:path:_files' \
-'--config=[User config file path]:path:_files' \
-'-f[Skip approval prompts]' \
-'--force[Skip approval prompts]' \
-'--all[Show all commands]' \
-'-v[Show commands and debug info]' \
-'--verbose[Show commands and debug info]' \
-'-h[Print help]' \
-'--help[Print help]' \
-&& ret=0
-;;
-(clear-approvals)
-_arguments "${_arguments_options[@]}" : \
-'-C+[Change working directory]:path:_files' \
-'--config=[User config file path]:path:_files' \
-'-g[Clear global approvals]' \
-'--global[Clear global approvals]' \
-'-v[Show commands and debug info]' \
-'--verbose[Show commands and debug info]' \
-'-h[Print help]' \
-'--help[Print help]' \
-&& ret=0
-;;
(select)
_arguments "${_arguments_options[@]}" : \
'-C+[Change working directory]:path:_files' \
@@ -563,22 +582,10 @@ _wt__beta_commands() {
'squash:Squash commits with LLM-generated message' \
'push:Push changes to local target branch' \
'rebase:Rebase onto target' \
-'ask-approvals:Store approvals in config' \
-'clear-approvals:Clear approved commands from config' \
'select:Interactive worktree selector' \
)
_describe -t commands 'wt beta commands' commands "$@"
}
-(( $+functions[_wt__beta__ask-approvals_commands] )) ||
-_wt__beta__ask-approvals_commands() {
- local commands; commands=()
- _describe -t commands 'wt beta ask-approvals commands' commands "$@"
-}
-(( $+functions[_wt__beta__clear-approvals_commands] )) ||
-_wt__beta__clear-approvals_commands() {
- local commands; commands=()
- _describe -t commands 'wt beta clear-approvals commands' commands "$@"
-}
(( $+functions[_wt__beta__commit_commands] )) ||
_wt__beta__commit_commands() {
local commands; commands=()
@@ -617,9 +624,28 @@ _wt__config_commands() {
'list:List configuration files & locations' \
'refresh-cache:Refresh default branch from remote' \
'status:Manage branch status markers' \
+'approvals:Manage command approvals' \
)
_describe -t commands 'wt config commands' commands "$@"
}
+(( $+functions[_wt__config__approvals_commands] )) ||
+_wt__config__approvals_commands() {
+ local commands; commands=(
+'ask:Store approvals in config' \
+'clear:Clear approved commands from config' \
+ )
+ _describe -t commands 'wt config approvals commands' commands "$@"
+}
+(( $+functions[_wt__config__approvals__ask_commands] )) ||
+_wt__config__approvals__ask_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt config approvals ask commands' commands "$@"
+}
+(( $+functions[_wt__config__approvals__clear_commands] )) ||
+_wt__config__approvals__clear_commands() {
+ local commands; commands=()
+ _describe -t commands 'wt config approvals clear commands' commands "$@"
+}
(( $+functions[_wt__config__create_commands] )) ||
_wt__config__create_commands() {
local commands; commands=()
diff --git a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap
index 19e400616..5422eb45a 100644
--- a/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap
+++ b/tests/snapshots/integration__integration_tests__merge__merge_rebase_conflict.snap
@@ -10,11 +10,8 @@ info:
COLUMNS: "150"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
- GIT_CONFIG_COUNT: "1"
- GIT_CONFIG_GLOBAL: /dev/null
- GIT_CONFIG_KEY_0: advice.mergeConflict
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
GIT_CONFIG_SYSTEM: /dev/null
- GIT_CONFIG_VALUE_0: "false"
GIT_EDITOR: ""
LANG: C
LC_ALL: C