Skip to content

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

Make state subcommands default to `get` action (#184)

Maximilian Roosb952d7870970
diff --git a/docs/content/config.md b/docs/content/config.md
index 7c86ca8f2..7b193152f 100644
--- a/docs/content/config.md
+++ b/docs/content/config.md
@@ -571,7 +571,7 @@ Global Options:
## wt config state
-State is stored in git config, separate from configuration files.
+State is stored in `.git/` (config entries and log files), separate from configuration files.
Use `wt config show` to view file-based configuration.
### Keys
@@ -586,7 +586,7 @@ Use `wt config show` to view file-based configuration.
Get the default branch:
```bash
-wt config state default-branch get
+wt config state default-branch
```
Set the default branch manually:
@@ -619,16 +619,16 @@ wt config state clear
### Command reference
```
-wt config state - Get, set, or clear stored state (git config)
+wt config state - Get, set, or clear stored state
Usage: wt config state [OPTIONS] <COMMAND>
Commands:
- default-branch Manage default branch setting
- previous-branch Manage previous branch (for wt switch -)
- ci-status Manage CI status cache
- marker Manage branch markers
- logs Manage background operation logs
+ default-branch Default branch setting
+ previous-branch Previous branch (for wt switch -)
+ ci-status CI status cache
+ marker Branch markers
+ logs Background operation logs
get Get all stored state
clear Clear all stored state
@@ -660,7 +660,7 @@ Commands:
shell Shell integration setup
create Create configuration file
show Show configuration files & locations
- state Get, set, or clear stored state (git config)
+ state Get, set, or clear stored state
Options:
-h, --help
diff --git a/src/cli.rs b/src/cli.rs
index d5eeca696..7c11408b2 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -388,9 +388,9 @@ commit messages."#
full: bool,
},
- /// Get, set, or clear stored state (git config)
+ /// Get, set, or clear stored state
#[command(
- after_long_help = r#"State is stored in git config, separate from configuration files.
+ after_long_help = r#"State is stored in `.git/` (config entries and log files), separate from configuration files.
Use `wt config show` to view file-based configuration.
## Keys
@@ -405,7 +405,7 @@ Use `wt config show` to view file-based configuration.
Get the default branch:
```console
-wt config state default-branch get
+wt config state default-branch
```
Set the default branch manually:
@@ -441,37 +441,46 @@ wt config state clear
#[derive(Subcommand)]
pub enum StateCommand {
- /// Manage default branch setting
- #[command(name = "default-branch")]
+ /// Default branch setting
+ #[command(
+ name = "default-branch",
+ after_long_help = "Without a subcommand, runs `get`. For `--refresh`, use `get --refresh`."
+ )]
DefaultBranch {
#[command(subcommand)]
- action: DefaultBranchAction,
+ action: Option<DefaultBranchAction>,
},
- /// Manage previous branch (for `wt switch -`)
+ /// Previous branch (for `wt switch -`)
#[command(name = "previous-branch")]
PreviousBranch {
#[command(subcommand)]
- action: PreviousBranchAction,
+ action: Option<PreviousBranchAction>,
},
- /// Manage CI status cache
- #[command(name = "ci-status")]
+ /// CI status cache
+ #[command(
+ name = "ci-status",
+ after_long_help = "Without a subcommand, runs `get` for the current branch. For `--branch` or `--refresh`, use `get --branch=NAME`."
+ )]
CiStatus {
#[command(subcommand)]
- action: CiStatusAction,
+ action: Option<CiStatusAction>,
},
- /// Manage branch markers
+ /// Branch markers
+ #[command(
+ after_long_help = "Without a subcommand, runs `get` for the current branch. For `--branch`, use `get --branch=NAME`."
+ )]
Marker {
#[command(subcommand)]
- action: MarkerAction,
+ action: Option<MarkerAction>,
},
- /// Manage background operation logs
+ /// Background operation logs
Logs {
#[command(subcommand)]
- action: LogsAction,
+ action: Option<LogsAction>,
},
/// Get all stored state
@@ -511,7 +520,7 @@ pub enum DefaultBranchAction {
Get the default branch:
```console
-wt config state default-branch get
+wt config state default-branch
```
Force refresh from remote:
@@ -548,7 +557,7 @@ pub enum PreviousBranchAction {
Get the previous branch (used by `wt switch -`):
```console
-wt config state previous-branch get
+wt config state previous-branch
```"#)]
Get,
@@ -579,7 +588,7 @@ pub enum CiStatusAction {
Get CI status for current branch:
```console
-wt config state ci-status get
+wt config state ci-status
```
Force refresh from GitHub/GitLab:
@@ -637,7 +646,7 @@ pub enum MarkerAction {
Get marker for current branch:
```console
-wt config state marker get
+wt config state marker
```
Get marker for a specific branch:
@@ -709,7 +718,7 @@ pub enum LogsAction {
List log files:
```console
-wt config state logs get
+wt config state logs
```"#
)]
Get,
diff --git a/src/main.rs b/src/main.rs
index 50d38991e..349c72e89 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -915,43 +915,50 @@ fn main() {
ConfigCommand::Show { full } => handle_config_show(full),
ConfigCommand::State { action } => match action {
StateCommand::DefaultBranch { action } => match action {
- DefaultBranchAction::Get { refresh } => {
+ Some(DefaultBranchAction::Get { refresh }) => {
handle_state_get("default-branch", refresh, None)
}
- DefaultBranchAction::Set { branch } => {
+ None => handle_state_get("default-branch", false, None),
+ Some(DefaultBranchAction::Set { branch }) => {
handle_state_set("default-branch", branch, None)
}
- DefaultBranchAction::Clear => handle_state_clear("default-branch", None, false),
+ Some(DefaultBranchAction::Clear) => {
+ handle_state_clear("default-branch", None, false)
+ }
},
StateCommand::PreviousBranch { action } => match action {
- PreviousBranchAction::Get => handle_state_get("previous-branch", false, None),
- PreviousBranchAction::Set { branch } => {
+ Some(PreviousBranchAction::Get) | None => {
+ handle_state_get("previous-branch", false, None)
+ }
+ Some(PreviousBranchAction::Set { branch }) => {
handle_state_set("previous-branch", branch, None)
}
- PreviousBranchAction::Clear => {
+ Some(PreviousBranchAction::Clear) => {
handle_state_clear("previous-branch", None, false)
}
},
StateCommand::CiStatus { action } => match action {
- CiStatusAction::Get { refresh, branch } => {
+ Some(CiStatusAction::Get { refresh, branch }) => {
handle_state_get("ci-status", refresh, branch)
}
- CiStatusAction::Clear { branch, all } => {
+ None => handle_state_get("ci-status", false, None),
+ Some(CiStatusAction::Clear { branch, all }) => {
handle_state_clear("ci-status", branch, all)
}
},
StateCommand::Marker { action } => match action {
- MarkerAction::Get { branch } => handle_state_get("marker", false, branch),
- MarkerAction::Set { value, branch } => {
+ Some(MarkerAction::Get { branch }) => handle_state_get("marker", false, branch),
+ None => handle_state_get("marker", false, None),
+ Some(MarkerAction::Set { value, branch }) => {
handle_state_set("marker", value, branch)
}
- MarkerAction::Clear { branch, all } => {
+ Some(MarkerAction::Clear { branch, all }) => {
handle_state_clear("marker", branch, all)
}
},
StateCommand::Logs { action } => match action {
- LogsAction::Get => handle_state_get("logs", false, None),
- LogsAction::Clear => handle_state_clear("logs", None, false),
+ Some(LogsAction::Get) | None => handle_state_get("logs", false, None),
+ Some(LogsAction::Clear) => handle_state_clear("logs", None, false),
},
StateCommand::Get { format } => handle_state_show(format),
StateCommand::Clear => handle_state_clear_all(),
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_long.snap b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
index 040e025a0..f409bffb7 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_long.snap
@@ -25,7 +25,7 @@ Usage: wt config [OPTIONS] <COMMAND>
shell Shell integration setup
create Create configuration file
show Show configuration files & locations
- state Get, set, or clear stored state (git config)
+ state Get, set, or clear stored state
Options:
-h, --help
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_short.snap b/tests/snapshots/integration__integration_tests__help__help_config_short.snap
index 54a91f29b..cea8b49c2 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_short.snap
@@ -25,7 +25,7 @@ Usage: wt config [OPTIONS] <COMMAND>
shell Shell integration setup
create Create configuration file
show Show configuration files & locations
- state Get, set, or clear stored state (git config)
+ state Get, set, or clear stored state
Options:
-h, --help Print help (see more with '--help')
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state.snap b/tests/snapshots/integration__integration_tests__help__help_config_state.snap
index 96167ce3c..b0480dc40 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state.snap
@@ -18,16 +18,16 @@ exit_code: 0
----- stdout -----
----- stderr -----
-wt config state - Get, set, or clear stored state (git config)
+wt config state - Get, set, or clear stored state
Usage: wt config state [OPTIONS] <COMMAND>
Commands:
- default-branch Manage default branch setting
- previous-branch Manage previous branch (for wt switch -)
- ci-status Manage CI status cache
- marker Manage branch markers
- logs Manage background operation logs
+ default-branch Default branch setting
+ previous-branch Previous branch (for wt switch -)
+ ci-status CI status cache
+ marker Branch markers
+ logs Background operation logs
get Get all stored state
clear Clear all stored state
@@ -45,7 +45,7 @@ Usage: wt config state [OPTIONS] <COMMAND>
-v, --verbose
Show commands and debug info
-State is stored in git config, separate from configuration files.
+State is stored in .git/ (config entries and log files), separate from configuration files.
Use wt config show to view file-based configuration.
Keys
@@ -59,7 +59,7 @@ Use wt config show to view file-based configuration.
Examples
Get the default branch:
- wt config state default-branch get
+ wt config state default-branch
Set the default branch manually:
wt config state default-branch set main
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_ci_status.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_ci_status.snap
index d2ad43791..c5ac658b1 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_ci_status.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_ci_status.snap
@@ -19,18 +19,26 @@ exit_code: 0
----- stdout -----
----- stderr -----
-wt config state ci-status - Manage CI status cache
+wt config state ci-status - CI status cache
-Usage: wt config state ci-status [OPTIONS] <COMMAND>
+Usage: wt config state ci-status [OPTIONS] [COMMAND]
Commands:
get Get CI status for a branch
clear Clear CI status cache
Options:
- -h, --help Print help
+ -h, --help
+ Print help (see a summary with '-h')
Global Options:
- -C <path> Working directory for this command
- --config <path> User config file path
- -v, --verbose Show commands and debug info
+ -C <path>
+ Working directory for this command
+
+ --config <path>
+ User config file path
+
+ -v, --verbose
+ Show commands and debug info
+
+Without a subcommand, runs get for the current branch. For --branch or --refresh, use get --branch=NAME.
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_default_branch.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_default_branch.snap
index 4304700fb..b579356fa 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_default_branch.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_default_branch.snap
@@ -19,9 +19,9 @@ exit_code: 0
----- stdout -----
----- stderr -----
-wt config state default-branch - Manage default branch setting
+wt config state default-branch - Default branch setting
-Usage: wt config state default-branch [OPTIONS] <COMMAND>
+Usage: wt config state default-branch [OPTIONS] [COMMAND]
Commands:
get Get the default branch
@@ -29,9 +29,17 @@ Usage: wt config state default-branch [OPTIONS] <COMM
clear Clear the default branch cache
Options:
- -h, --help Print help
+ -h, --help
+ Print help (see a summary with '-h')
Global Options:
- -C <path> Working directory for this command
- --config <path> User config file path
- -v, --verbose Show commands and debug info
+ -C <path>
+ Working directory for this command
+
+ --config <path>
+ User config file path
+
+ -v, --verbose
+ Show commands and debug info
+
+Without a subcommand, runs get. For --refresh, use get --refresh.
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
index fde16e0bf..ba07e47f6 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_logs.snap
@@ -19,9 +19,9 @@ exit_code: 0
----- stdout -----
----- stderr -----
-wt config state logs - Manage background operation logs
+wt config state logs - Background operation logs
-Usage: wt config state logs [OPTIONS] <COMMAND>
+Usage: wt config state logs [OPTIONS] [COMMAND]
Commands:
get List background operation log files
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_marker.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_marker.snap
index 23d809db7..8d93ae687 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_marker.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_marker.snap
@@ -19,9 +19,9 @@ exit_code: 0
----- stdout -----
----- stderr -----
-wt config state marker - Manage branch markers
+wt config state marker - Branch markers
-Usage: wt config state marker [OPTIONS] <COMMAND>
+Usage: wt config state marker [OPTIONS] [COMMAND]
Commands:
get Get marker for a branch
@@ -29,9 +29,17 @@ Usage: wt config state marker [OPTIONS] <COMMAND>
clear Clear marker for a branch
Options:
- -h, --help Print help
+ -h, --help
+ Print help (see a summary with '-h')
Global Options:
- -C <path> Working directory for this command
- --config <path> User config file path
- -v, --verbose Show commands and debug info
+ -C <path>
+ Working directory for this command
+
+ --config <path>
+ User config file path
+
+ -v, --verbose
+ Show commands and debug info
+
+Without a subcommand, runs get for the current branch. For --branch, use get --branch=NAME.
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_previous_branch.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_previous_branch.snap
index bcb05a4d5..27d760a31 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_previous_branch.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_previous_branch.snap
@@ -19,9 +19,9 @@ exit_code: 0
----- stdout -----
----- stderr -----
-wt config state previous-branch - Manage previous branch (for wt switch -)
+wt config state previous-branch - Previous branch (for wt switch -)
-Usage: wt config state previous-branch [OPTIONS] <COMMAND>
+Usage: wt config state previous-branch [OPTIONS] [COMMAND]
Commands:
get Get the previous branch