diff options
| author | akbash <akbash@herdr.dev> | 2026-08-01 23:55:04 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-01 23:55:04 +0300 |
| commit | 9a4ce5e13c1d4622ca63c2947d0eaa018ec35715 (patch) | |
| tree | 3625ab9d9bd473d10f9c1f6d7ef1928d6c3f1030 /src | |
| parent | 6fb0d803573353f031927a429828ab3b56c6c400 (diff) | |
fix: stop advertising worktree json flag (#2174)
refs #2171
Co-authored-by: akbash-bot <300245827+akbash-bot@users.noreply.github.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cli/spec.rs | 24 | ||||
| -rw-r--r-- | src/cli/worktree.rs | 19 |
2 files changed, 26 insertions, 17 deletions
diff --git a/src/cli/spec.rs b/src/cli/spec.rs index 1f2e85a4..3be83328 100644 --- a/src/cli/spec.rs +++ b/src/cli/spec.rs @@ -229,8 +229,7 @@ fn worktree_command() -> Command { Command::new("list") .about("List worktree workspaces") .arg(option("workspace", "ID")) - .arg(path_option("cwd", "PATH")) - .arg(json_flag()), + .arg(path_option("cwd", "PATH")), ) .subcommand( Command::new("create") @@ -242,8 +241,7 @@ fn worktree_command() -> Command { .arg(path_option("path", "PATH")) .arg(option("label", "TEXT")) .arg(flag("focus")) - .arg(flag("no-focus")) - .arg(json_flag()), + .arg(flag("no-focus")), ) .subcommand( Command::new("open") @@ -254,15 +252,13 @@ fn worktree_command() -> Command { .arg(option("branch", "NAME")) .arg(option("label", "TEXT")) .arg(flag("focus")) - .arg(flag("no-focus")) - .arg(json_flag()), + .arg(flag("no-focus")), ) .subcommand( Command::new("remove") .about("Remove a worktree checkout") .arg(option("workspace", "ID")) - .arg(flag("force")) - .arg(json_flag()), + .arg(flag("force")), ) } @@ -1192,6 +1188,18 @@ mod tests { } #[test] + fn worktree_json_compatibility_flag_stays_out_of_public_spec() { + let cmd = super::command(); + for subcommand in ["list", "create", "open", "remove"] { + let worktree_command = command_path(&cmd, &["worktree", subcommand]); + assert!( + !has_option(worktree_command, "json"), + "herdr worktree {subcommand} should not advertise --json" + ); + } + } + + #[test] fn spec_includes_nested_plugin_pane_open_options() { let cmd = super::command(); let open = command_path(&cmd, &["plugin", "pane", "open"]); diff --git a/src/cli/worktree.rs b/src/cli/worktree.rs index b96bcb8f..4a36876a 100644 --- a/src/cli/worktree.rs +++ b/src/cli/worktree.rs @@ -2,6 +2,7 @@ use crate::api::schema::{ WorktreeCreateParams, WorktreeListParams, WorktreeOpenParams, WorktreeRemoveParams, }; +// Worktree output is always JSON. The parsers retain `--json` as a hidden compatibility no-op. pub(super) fn run_worktree_command(args: &[String]) -> std::io::Result<i32> { let Some(subcommand) = args.first().map(|arg| arg.as_str()) else { print_worktree_help(); @@ -55,7 +56,7 @@ fn worktree_list(args: &[String]) -> std::io::Result<i32> { } } if workspace_id.is_some() && cwd.is_some() { - eprintln!("usage: herdr worktree list [--workspace ID | --cwd PATH] [--json]"); + eprintln!("usage: herdr worktree list [--workspace ID | --cwd PATH]"); return Ok(2); } @@ -139,7 +140,7 @@ fn worktree_create(args: &[String]) -> std::io::Result<i32> { } if workspace_id.is_some() && cwd.is_some() { eprintln!( - "usage: herdr worktree create [--workspace ID | --cwd PATH] [--branch NAME] [--base REF] [--path PATH] [--label TEXT] [--focus] [--no-focus] [--json]" + "usage: herdr worktree create [--workspace ID | --cwd PATH] [--branch NAME] [--base REF] [--path PATH] [--label TEXT] [--focus] [--no-focus]" ); return Ok(2); } @@ -223,13 +224,13 @@ fn worktree_open(args: &[String]) -> std::io::Result<i32> { } if workspace_id.is_some() && cwd.is_some() { eprintln!( - "usage: herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus] [--json]" + "usage: herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus]" ); return Ok(2); } if path.is_some() == branch.is_some() { eprintln!( - "usage: herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus] [--json]" + "usage: herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus]" ); return Ok(2); } @@ -272,7 +273,7 @@ fn worktree_remove(args: &[String]) -> std::io::Result<i32> { } let Some(workspace_id) = workspace_id else { - eprintln!("usage: herdr worktree remove --workspace ID [--force] [--json]"); + eprintln!("usage: herdr worktree remove --workspace ID [--force]"); return Ok(2); }; @@ -284,14 +285,14 @@ fn worktree_remove(args: &[String]) -> std::io::Result<i32> { fn print_worktree_help() { eprintln!("herdr worktree commands:"); - eprintln!(" herdr worktree list [--workspace ID | --cwd PATH] [--json]"); + eprintln!(" herdr worktree list [--workspace ID | --cwd PATH]"); eprintln!( - " herdr worktree create [--workspace ID | --cwd PATH] [--branch NAME] [--base REF] [--path PATH] [--label TEXT] [--focus] [--no-focus] [--json]" + " herdr worktree create [--workspace ID | --cwd PATH] [--branch NAME] [--base REF] [--path PATH] [--label TEXT] [--focus] [--no-focus]" ); eprintln!( - " herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus] [--json]" + " herdr worktree open [--workspace ID | --cwd PATH] (--path PATH | --branch NAME) [--label TEXT] [--focus] [--no-focus]" ); - eprintln!(" herdr worktree remove --workspace ID [--force] [--json]"); + eprintln!(" herdr worktree remove --workspace ID [--force]"); } fn normalize_path_arg(value: &str) -> std::io::Result<String> { |
