Skip to content

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

refactor(cli): split StatuslineFormat from OutputFormat (#3116)

Maximilian Roos47180a7035b6
diff --git a/docs/content/list.md b/docs/content/list.md
index 76f2413d0..2ee88aec2 100644
--- a/docs/content/list.md
+++ b/docs/content/list.md
@@ -286,9 +286,10 @@ Usage: <b><span class=c>wt list</span></b> <span class=c>[OPTIONS]</span>
<b><span class=g>Options:</span></b>
<b><span class=c>--format</span></b><span class=c> &lt;FORMAT&gt;</span>
- Output format (table, json)
+ Output format
[default: table]
+ [possible values: table, json]
<b><span class=c>--branches</span></b>
Include branches without worktrees
diff --git a/skills/worktrunk/reference/list.md b/skills/worktrunk/reference/list.md
index 1f0ddf73f..74cf09086 100644
--- a/skills/worktrunk/reference/list.md
+++ b/skills/worktrunk/reference/list.md
@@ -293,9 +293,10 @@ Commands:
Options:
--format <FORMAT>
- Output format (table, json)
+ Output format
[default: table]
+ [possible values: table, json]
--branches
Include branches without worktrees
diff --git a/src/cli/config.rs b/src/cli/config.rs
index cf0667fa9..39a3de6e7 100644
--- a/src/cli/config.rs
+++ b/src/cli/config.rs
@@ -696,8 +696,8 @@ Every category that `wt config state clear` sweeps is shown here.
CI cache entries show status, age, and the commit SHA they were fetched for."#)]
Get {
- /// Output format (table, json)
- #[arg(long, value_enum, default_value = "table", hide_possible_values = true)]
+ /// Output format
+ #[arg(long, value_enum, default_value = "table")]
format: super::OutputFormat,
},
diff --git a/src/cli/list.rs b/src/cli/list.rs
index 54ed0cb3d..c1a9a2d6b 100644
--- a/src/cli/list.rs
+++ b/src/cli/list.rs
@@ -1,6 +1,6 @@
use clap::Subcommand;
-use super::OutputFormat;
+use super::StatuslineFormat;
/// Subcommands for `wt list`
#[derive(Subcommand)]
@@ -27,7 +27,7 @@ The pace segment appears only when usage is likely to hit a rate limit before it
Statusline {
/// Output format
#[arg(long, value_enum, default_value = "table")]
- format: OutputFormat,
+ format: StatuslineFormat,
/// Deprecated: use --format=claude-code
#[arg(long, hide = true)]
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index c6a6e3d79..a9d012f9c 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -183,12 +183,18 @@ pub(crate) enum SwitchFormat {
Json,
}
-// TODO: ClaudeCode is statusline-specific but lives in this shared enum, forcing
-// unrelated codepaths to handle it. Consider a dedicated StatuslineFormat enum.
+/// Output format for `wt list` and `wt config state get` (table or JSON).
#[derive(Debug, Clone, Copy, clap::ValueEnum)]
pub(crate) enum OutputFormat {
Table,
Json,
+}
+
+/// Output format for `wt list statusline`, including the Claude Code mode.
+#[derive(Debug, Clone, Copy, clap::ValueEnum)]
+pub(crate) enum StatuslineFormat {
+ Table,
+ Json,
/// Claude Code statusline mode (reads context from stdin)
#[value(name = "claude-code")]
ClaudeCode,
@@ -390,8 +396,8 @@ pub(crate) struct ListArgs {
#[command(subcommand)]
pub(crate) subcommand: Option<ListSubcommand>,
- /// Output format (table, json)
- #[arg(long, value_enum, default_value = "table", hide_possible_values = true)]
+ /// Output format
+ #[arg(long, value_enum, default_value = "table")]
pub(crate) format: OutputFormat,
/// Include branches without worktrees
diff --git a/src/commands/config/state.rs b/src/commands/config/state.rs
index e8c0c7dc9..535237a6b 100644
--- a/src/commands/config/state.rs
+++ b/src/commands/config/state.rs
@@ -1178,7 +1178,7 @@ pub fn handle_state_show(format: OutputFormat) -> anyhow::Result<()> {
match format {
OutputFormat::Json => handle_state_show_json(&repo),
- OutputFormat::Table | OutputFormat::ClaudeCode => handle_state_show_table(&repo),
+ OutputFormat::Table => handle_state_show_table(&repo),
}
}
diff --git a/src/commands/list/progressive.rs b/src/commands/list/progressive.rs
index 6e2ba71fb..f47723553 100644
--- a/src/commands/list/progressive.rs
+++ b/src/commands/list/progressive.rs
@@ -24,7 +24,7 @@ impl RenderTarget {
pub fn detect(format: OutputFormat, progressive_flag: Option<bool>) -> Self {
match format {
OutputFormat::Json => RenderTarget::Json,
- OutputFormat::Table | OutputFormat::ClaudeCode => {
+ OutputFormat::Table => {
let is_tty = std::io::stdout().is_terminal();
let progressive = match progressive_flag {
Some(p) => p && is_tty,
diff --git a/src/commands/statusline.rs b/src/commands/statusline.rs
index d9be84c2d..b4daa64b7 100644
--- a/src/commands/statusline.rs
+++ b/src/commands/statusline.rs
@@ -21,7 +21,7 @@ use worktrunk::styling::{
};
use super::list::{self, CollectOptions, StatuslineSegment, json_output};
-use crate::cli::OutputFormat;
+use crate::cli::StatuslineFormat;
/// Claude Code context parsed from stdin JSON
struct ClaudeCodeContext {
@@ -561,17 +561,17 @@ fn format_context_gauge(percentage: f64) -> String {
///
/// Output uses `println!` for raw stdout (bypasses anstream color detection).
/// Shell prompts (PS1) and Claude Code always expect ANSI codes.
-pub fn run(format: OutputFormat) -> Result<()> {
+pub fn run(format: StatuslineFormat) -> Result<()> {
// Statusline runs on every prompt redraw — deprecation warnings on stderr
// would appear above each prompt.
worktrunk::config::suppress_warnings();
// JSON format: output current worktree as JSON
- if matches!(format, OutputFormat::Json) {
+ if matches!(format, StatuslineFormat::Json) {
return run_json();
}
- let claude_code = matches!(format, OutputFormat::ClaudeCode);
+ let claude_code = matches!(format, StatuslineFormat::ClaudeCode);
// Get context - either from stdin (claude-code mode) or current directory
let (cwd, model_name, context_used_percentage, rate_limits) = if claude_code {
diff --git a/src/main.rs b/src/main.rs
index 9429d3121..3ea01642c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -33,7 +33,7 @@ pub(crate) use invocation::{
binary_name, invocation_path, is_git_subcommand, was_invoked_with_explicit_path,
};
-pub(crate) use crate::cli::OutputFormat;
+pub(crate) use crate::cli::{OutputFormat, StatuslineFormat};
use commands::commit::HookGate;
#[cfg(unix)]
@@ -646,8 +646,8 @@ fn handle_list_command(args: ListArgs) -> anyhow::Result<()> {
}
// Hidden --claude-code flag only applies when format is default (Table)
// Explicit --format=json takes precedence over --claude-code
- let effective_format = if claude_code && matches!(format, OutputFormat::Table) {
- OutputFormat::ClaudeCode
+ let effective_format = if claude_code && matches!(format, StatuslineFormat::Table) {
+ StatuslineFormat::ClaudeCode
} else {
format
};
diff --git a/tests/snapshots/integration__integration_tests__help__help_config_state_get.snap b/tests/snapshots/integration__integration_tests__help__help_config_state_get.snap
index c01671a99..93699a561 100644
--- a/tests/snapshots/integration__integration_tests__help__help_config_state_get.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_config_state_get.snap
@@ -40,9 +40,10 @@ Usage: wt config state get [OPTIONS]
Options:
--format <FORMAT>
- Output format (table, json)
+ Output format
[default: table]
+ [possible values: table, json]
-h, --help
Print help (see a summary with '-h')
diff --git a/tests/snapshots/integration__integration_tests__help__help_list_long.snap b/tests/snapshots/integration__integration_tests__help__help_list_long.snap
index b04e5bcb0..ed766db72 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list_long.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list_long.snap
@@ -42,9 +42,10 @@ Usage: wt list [OPTIONS]
Options:
--format <FORMAT>
- Output format (table, json)
+ Output format
[default: table]
+ [possible values: table, json]
--branches
Include branches without worktrees
diff --git a/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap b/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap
index 1ff95b79f..b54aee7d6 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list_narrow_80.snap
@@ -42,9 +42,10 @@ Usage: wt list [OPTIONS]
Options:
--format <FORMAT>
- Output format (table, json)
+ Output format
[default: table]
+ [possible values: table, json]
--branches
Include branches without worktrees
diff --git a/tests/snapshots/integration__integration_tests__help__help_list_short.snap b/tests/snapshots/integration__integration_tests__help__help_list_short.snap
index 3d39563fe..6d097a790 100644
--- a/tests/snapshots/integration__integration_tests__help__help_list_short.snap
+++ b/tests/snapshots/integration__integration_tests__help__help_list_short.snap
@@ -41,7 +41,7 @@ Usage: wt list [OPTIONS]
statusline Single-line status for shell prompts
Options:
- --format <FORMAT> Output format (table, json) [default: table]
+ --format <FORMAT> Output format [default: table] [possible values: table, json]
--branches Include branches without worktrees
--remotes Include remote branches
--full Show CI, diff analysis, and LLM summaries