From 8869e6d0890b6cfd93a1f4c4e4a0d3c3a6968b40 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 8 Sep 2025 06:49:34 -0600 Subject: [PATCH 1/6] fix: use newline for separator in misuse text --- crates/turborepo-lib/src/cli/mod.rs | 115 +++++++++++++------ turborepo-tests/integration/tests/bad-flag.t | 30 ++++- 2 files changed, 109 insertions(+), 36 deletions(-) diff --git a/crates/turborepo-lib/src/cli/mod.rs b/crates/turborepo-lib/src/cli/mod.rs index 990edce842b7c..eb60806404117 100644 --- a/crates/turborepo-lib/src/cli/mod.rs +++ b/crates/turborepo-lib/src/cli/mod.rs @@ -9,10 +9,10 @@ use std::{ use biome_deserialize_macros::Deserializable; use camino::{Utf8Path, Utf8PathBuf}; use clap::{ - builder::NonEmptyStringValueParser, ArgAction, ArgGroup, CommandFactory, Parser, Subcommand, - ValueEnum, + ArgAction, ArgGroup, CommandFactory, Parser, Subcommand, ValueEnum, + builder::NonEmptyStringValueParser, }; -use clap_complete::{generate, Shell}; +use clap_complete::{Shell, generate}; pub use error::Error; use serde::{Deserialize, Serialize}; use tracing::{debug, error, log::warn}; @@ -20,16 +20,17 @@ use turbopath::AbsoluteSystemPathBuf; use turborepo_api_client::AnonAPIClient; use turborepo_repository::inference::{RepoMode, RepoState}; use turborepo_telemetry::{ - events::{command::CommandEventBuilder, generic::GenericEventBuilder, EventBuilder, EventType}, - init_telemetry, track_usage, TelemetryHandle, + TelemetryHandle, + events::{EventBuilder, EventType, command::CommandEventBuilder, generic::GenericEventBuilder}, + init_telemetry, track_usage, }; use turborepo_ui::{ColorConfig, GREY}; use crate::{ cli::error::print_potential_tasks, commands::{ - bin, boundaries, clone, config, daemon, generate, info, link, login, logout, ls, prune, - query, run, scan, telemetry, unlink, CommandBase, + CommandBase, bin, boundaries, clone, config, daemon, generate, info, link, login, logout, + ls, prune, query, run, scan, telemetry, unlink, }, get_version, run::watch::WatchClient, @@ -372,7 +373,49 @@ impl Args { process::exit(1); } Err(e) if e.use_stderr() => { - let err_str = e.to_string(); + let mut err_str = e.to_string(); + + // Replace pipe separators in usage line with newlines for better readability + // The usage line typically looks like: "Usage: turbo <--opt1|--opt2|--opt3>" + if let Some(usage_start) = err_str.find("Usage: ") { + if let Some(usage_end) = err_str[usage_start..].find('\n') { + let usage_end = usage_start + usage_end; + let usage_line = &err_str[usage_start..usage_end]; + + // Check if this usage line contains the pipe-separated options pattern + if usage_line.contains('<') + && usage_line.contains('>') + && usage_line.contains('|') + { + // Find the angle bracket enclosed section + if let Some(bracket_start) = usage_line.find('<') { + if let Some(bracket_end) = usage_line.rfind('>') { + let prefix = &usage_line[..bracket_start]; + let options_str = &usage_line[bracket_start + 1..bracket_end]; + let suffix = &usage_line[bracket_end + 1..]; + + // Split the options by pipe and format them as a list + let formatted_options: Vec = options_str + .split('|') + .map(|opt| format!(" {}", opt)) + .collect(); + + // Build the new usage string + let new_usage = format!( + "{} [OPTIONS] [TASKS]... [-- \ + ...]\n\nOptions:\n{}", + prefix.trim_end(), + formatted_options.join("\n") + ); + + // Replace the old usage line with the new formatted one + err_str.replace_range(usage_start..usage_end, &new_usage); + } + } + } + } + } + // A cleaner solution would be to implement our own clap::error::ErrorFormatter // but that would require copying the default formatter just to remove this // line: https://docs.rs/clap/latest/src/clap/error/format.rs.html#100 @@ -1497,11 +1540,7 @@ pub async fn run( event.track_call(); let base = CommandBase::new(cli_args.clone(), repo_root, version, color_config)?; event.track_ui_mode(base.opts.run_opts.ui_mode); - if scan::run(base).await { - Ok(0) - } else { - Ok(1) - } + if scan::run(base).await { Ok(0) } else { Ok(1) } } Command::Config => { CommandEventBuilder::new("config") @@ -3157,15 +3196,17 @@ mod test { assert!(Args::try_parse_from(["turbo", "build", "--anon-profile", ""]).is_err()); assert!(Args::try_parse_from(["turbo", "build", "--profile", "foo.json"]).is_ok()); assert!(Args::try_parse_from(["turbo", "build", "--anon-profile", "foo.json"]).is_ok()); - assert!(Args::try_parse_from([ - "turbo", - "build", - "--profile", - "foo.json", - "--anon-profile", - "bar.json" - ]) - .is_err()); + assert!( + Args::try_parse_from([ + "turbo", + "build", + "--profile", + "foo.json", + "--anon-profile", + "bar.json" + ]) + .is_err() + ); } #[test] @@ -3306,19 +3347,23 @@ mod test { .collect(), ) .unwrap(); - assert!(inferred_run - .execution_args - .as_ref() - .is_some_and(|e| e.single_package)); - assert!(explicit_run - .command - .as_ref() - .and_then(|cmd| if let Command::Run { execution_args, .. } = cmd { - Some(execution_args.single_package) - } else { - None - }) - .unwrap_or(false)); + assert!( + inferred_run + .execution_args + .as_ref() + .is_some_and(|e| e.single_package) + ); + assert!( + explicit_run + .command + .as_ref() + .and_then(|cmd| if let Command::Run { execution_args, .. } = cmd { + Some(execution_args.single_package) + } else { + None + }) + .unwrap_or(false) + ); } #[test_case::test_case(&["turbo", "watch", "build", "--no-daemon"]; "after watch")] diff --git a/turborepo-tests/integration/tests/bad-flag.t b/turborepo-tests/integration/tests/bad-flag.t index a5c5a4ea978ec..09e8589b8e5a4 100644 --- a/turborepo-tests/integration/tests/bad-flag.t +++ b/turborepo-tests/integration/tests/bad-flag.t @@ -19,7 +19,35 @@ Bad flag with an implied run command should display run flags tip: to pass '--bad-flag' as a value, use '-- --bad-flag' - Usage: turbo(\.exe)? <--cache-dir |--cache-workers |--concurrency |--continue|--dry-run []|--single-package|--filter |--force []|--framework-inference []|--global-deps |--graph []|--env-mode []|--ignore |--no-cache|--no-daemon|--output-logs |--log-order |--only|--parallel|--pkg-inference-root |--profile |--remote-only []|--summarize []|--log-prefix |TASKS|PASS_THROUGH_ARGS> (re) + Usage: turbo(\.exe)? \[OPTIONS\] \[TASKS\]... \[-- ...\] (re) + + Options: + --cache-dir + --cache-workers + --concurrency + --continue + --dry-run \[\] (re) + --single-package + --filter + --force \[\] (re) + --framework-inference \[\] (re) + --global-deps + --graph \[\] (re) + --env-mode \[\] (re) + --ignore + --no-cache + --no-daemon + --output-logs + --log-order + --only + --parallel + --pkg-inference-root + --profile + --remote-only \[\] (re) + --summarize \[\] (re) + --log-prefix + TASKS + PASS_THROUGH_ARGS For more information, try '--help'. From fb2460310e51df85b9d7f23ad46bf09e4040ab88 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 8 Sep 2025 06:49:48 -0600 Subject: [PATCH 2/6] fix: use newline for separator in misuse text --- crates/turborepo-lib/src/cli/error.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/turborepo-lib/src/cli/error.rs b/crates/turborepo-lib/src/cli/error.rs index 2bdf90c9d3c35..249392352b1f1 100644 --- a/crates/turborepo-lib/src/cli/error.rs +++ b/crates/turborepo-lib/src/cli/error.rs @@ -4,12 +4,12 @@ use itertools::Itertools; use miette::Diagnostic; use thiserror::Error; use turborepo_repository::package_graph; -use turborepo_signals::{listeners::get_signal, SignalHandler}; +use turborepo_signals::{SignalHandler, listeners::get_signal}; use turborepo_telemetry::events::command::CommandEventBuilder; -use turborepo_ui::{color, BOLD, GREY}; +use turborepo_ui::{BOLD, GREY, color}; use crate::{ - commands::{bin, generate, link, login, ls, prune, CommandBase}, + commands::{CommandBase, bin, generate, link, login, ls, prune}, daemon::DaemonError, query, rewrite_json::RewriteError, From cc49c77403e6190e9a7ee6147e65136de7e4cd4e Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 8 Sep 2025 06:57:16 -0600 Subject: [PATCH 3/6] WIP --- crates/turborepo-lib/src/cli/error.rs | 6 +-- crates/turborepo-lib/src/cli/mod.rs | 71 +++++++++++++-------------- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/crates/turborepo-lib/src/cli/error.rs b/crates/turborepo-lib/src/cli/error.rs index 249392352b1f1..2bdf90c9d3c35 100644 --- a/crates/turborepo-lib/src/cli/error.rs +++ b/crates/turborepo-lib/src/cli/error.rs @@ -4,12 +4,12 @@ use itertools::Itertools; use miette::Diagnostic; use thiserror::Error; use turborepo_repository::package_graph; -use turborepo_signals::{SignalHandler, listeners::get_signal}; +use turborepo_signals::{listeners::get_signal, SignalHandler}; use turborepo_telemetry::events::command::CommandEventBuilder; -use turborepo_ui::{BOLD, GREY, color}; +use turborepo_ui::{color, BOLD, GREY}; use crate::{ - commands::{CommandBase, bin, generate, link, login, ls, prune}, + commands::{bin, generate, link, login, ls, prune, CommandBase}, daemon::DaemonError, query, rewrite_json::RewriteError, diff --git a/crates/turborepo-lib/src/cli/mod.rs b/crates/turborepo-lib/src/cli/mod.rs index eb60806404117..b5f299b6f6541 100644 --- a/crates/turborepo-lib/src/cli/mod.rs +++ b/crates/turborepo-lib/src/cli/mod.rs @@ -9,10 +9,10 @@ use std::{ use biome_deserialize_macros::Deserializable; use camino::{Utf8Path, Utf8PathBuf}; use clap::{ - ArgAction, ArgGroup, CommandFactory, Parser, Subcommand, ValueEnum, - builder::NonEmptyStringValueParser, + builder::NonEmptyStringValueParser, ArgAction, ArgGroup, CommandFactory, Parser, Subcommand, + ValueEnum, }; -use clap_complete::{Shell, generate}; +use clap_complete::{generate, Shell}; pub use error::Error; use serde::{Deserialize, Serialize}; use tracing::{debug, error, log::warn}; @@ -20,17 +20,16 @@ use turbopath::AbsoluteSystemPathBuf; use turborepo_api_client::AnonAPIClient; use turborepo_repository::inference::{RepoMode, RepoState}; use turborepo_telemetry::{ - TelemetryHandle, - events::{EventBuilder, EventType, command::CommandEventBuilder, generic::GenericEventBuilder}, - init_telemetry, track_usage, + events::{command::CommandEventBuilder, generic::GenericEventBuilder, EventBuilder, EventType}, + init_telemetry, track_usage, TelemetryHandle, }; use turborepo_ui::{ColorConfig, GREY}; use crate::{ cli::error::print_potential_tasks, commands::{ - CommandBase, bin, boundaries, clone, config, daemon, generate, info, link, login, logout, - ls, prune, query, run, scan, telemetry, unlink, + bin, boundaries, clone, config, daemon, generate, info, link, login, logout, ls, prune, + query, run, scan, telemetry, unlink, CommandBase, }, get_version, run::watch::WatchClient, @@ -1540,7 +1539,11 @@ pub async fn run( event.track_call(); let base = CommandBase::new(cli_args.clone(), repo_root, version, color_config)?; event.track_ui_mode(base.opts.run_opts.ui_mode); - if scan::run(base).await { Ok(0) } else { Ok(1) } + if scan::run(base).await { + Ok(0) + } else { + Ok(1) + } } Command::Config => { CommandEventBuilder::new("config") @@ -3196,17 +3199,15 @@ mod test { assert!(Args::try_parse_from(["turbo", "build", "--anon-profile", ""]).is_err()); assert!(Args::try_parse_from(["turbo", "build", "--profile", "foo.json"]).is_ok()); assert!(Args::try_parse_from(["turbo", "build", "--anon-profile", "foo.json"]).is_ok()); - assert!( - Args::try_parse_from([ - "turbo", - "build", - "--profile", - "foo.json", - "--anon-profile", - "bar.json" - ]) - .is_err() - ); + assert!(Args::try_parse_from([ + "turbo", + "build", + "--profile", + "foo.json", + "--anon-profile", + "bar.json" + ]) + .is_err()); } #[test] @@ -3347,23 +3348,19 @@ mod test { .collect(), ) .unwrap(); - assert!( - inferred_run - .execution_args - .as_ref() - .is_some_and(|e| e.single_package) - ); - assert!( - explicit_run - .command - .as_ref() - .and_then(|cmd| if let Command::Run { execution_args, .. } = cmd { - Some(execution_args.single_package) - } else { - None - }) - .unwrap_or(false) - ); + assert!(inferred_run + .execution_args + .as_ref() + .is_some_and(|e| e.single_package)); + assert!(explicit_run + .command + .as_ref() + .and_then(|cmd| if let Command::Run { execution_args, .. } = cmd { + Some(execution_args.single_package) + } else { + None + }) + .unwrap_or(false)); } #[test_case::test_case(&["turbo", "watch", "build", "--no-daemon"]; "after watch")] From 05b271a6b92077da07d461552d5aa45e54b1170a Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 8 Sep 2025 07:02:17 -0600 Subject: [PATCH 4/6] simplify --- crates/turborepo-lib/src/cli/mod.rs | 155 ++++++++++++++-------------- 1 file changed, 78 insertions(+), 77 deletions(-) diff --git a/crates/turborepo-lib/src/cli/mod.rs b/crates/turborepo-lib/src/cli/mod.rs index b5f299b6f6541..4b127ca2c1e53 100644 --- a/crates/turborepo-lib/src/cli/mod.rs +++ b/crates/turborepo-lib/src/cli/mod.rs @@ -9,10 +9,10 @@ use std::{ use biome_deserialize_macros::Deserializable; use camino::{Utf8Path, Utf8PathBuf}; use clap::{ - builder::NonEmptyStringValueParser, ArgAction, ArgGroup, CommandFactory, Parser, Subcommand, - ValueEnum, + ArgAction, ArgGroup, CommandFactory, Parser, Subcommand, ValueEnum, + builder::NonEmptyStringValueParser, }; -use clap_complete::{generate, Shell}; +use clap_complete::{Shell, generate}; pub use error::Error; use serde::{Deserialize, Serialize}; use tracing::{debug, error, log::warn}; @@ -20,16 +20,17 @@ use turbopath::AbsoluteSystemPathBuf; use turborepo_api_client::AnonAPIClient; use turborepo_repository::inference::{RepoMode, RepoState}; use turborepo_telemetry::{ - events::{command::CommandEventBuilder, generic::GenericEventBuilder, EventBuilder, EventType}, - init_telemetry, track_usage, TelemetryHandle, + TelemetryHandle, + events::{EventBuilder, EventType, command::CommandEventBuilder, generic::GenericEventBuilder}, + init_telemetry, track_usage, }; use turborepo_ui::{ColorConfig, GREY}; use crate::{ cli::error::print_potential_tasks, commands::{ - bin, boundaries, clone, config, daemon, generate, info, link, login, logout, ls, prune, - query, run, scan, telemetry, unlink, CommandBase, + CommandBase, bin, boundaries, clone, config, daemon, generate, info, link, login, logout, + ls, prune, query, run, scan, telemetry, unlink, }, get_version, run::watch::WatchClient, @@ -357,6 +358,46 @@ pub enum LinkTarget { Spaces, } +/// Formats clap error messages to improve readability of pipe-separated options +fn format_error_message(mut err_str: String) -> String { + // Replace pipe separators in usage line with newlines for better readability + // The usage line typically looks like: "Usage: turbo <--opt1|--opt2|--opt3>" + if let Some(usage_start) = err_str.find("Usage: ") { + if let Some(usage_end) = err_str[usage_start..].find('\n') { + let usage_end = usage_start + usage_end; + let usage_line = &err_str[usage_start..usage_end]; + + // Check if this usage line contains the pipe-separated options pattern + if usage_line.contains('<') && usage_line.contains('>') && usage_line.contains('|') { + // Find the angle bracket enclosed section + if let Some(bracket_start) = usage_line.find('<') { + if let Some(bracket_end) = usage_line.rfind('>') { + let prefix = &usage_line[..bracket_start]; + let options_str = &usage_line[bracket_start + 1..bracket_end]; + + // Split the options by pipe and format them as a list + let formatted_options: Vec = options_str + .split('|') + .map(|opt| format!(" {}", opt)) + .collect(); + + // Build the new usage string + let new_usage = format!( + "{} [OPTIONS] [TASKS]... [-- ...]\n\nOptions:\n{}", + prefix.trim_end(), + formatted_options.join("\n") + ); + + // Replace the old usage line with the new formatted one + err_str.replace_range(usage_start..usage_end, &new_usage); + } + } + } + } + } + err_str +} + impl Args { pub fn new(os_args: Vec) -> Self { let clap_args = match Args::parse(os_args) { @@ -372,49 +413,7 @@ impl Args { process::exit(1); } Err(e) if e.use_stderr() => { - let mut err_str = e.to_string(); - - // Replace pipe separators in usage line with newlines for better readability - // The usage line typically looks like: "Usage: turbo <--opt1|--opt2|--opt3>" - if let Some(usage_start) = err_str.find("Usage: ") { - if let Some(usage_end) = err_str[usage_start..].find('\n') { - let usage_end = usage_start + usage_end; - let usage_line = &err_str[usage_start..usage_end]; - - // Check if this usage line contains the pipe-separated options pattern - if usage_line.contains('<') - && usage_line.contains('>') - && usage_line.contains('|') - { - // Find the angle bracket enclosed section - if let Some(bracket_start) = usage_line.find('<') { - if let Some(bracket_end) = usage_line.rfind('>') { - let prefix = &usage_line[..bracket_start]; - let options_str = &usage_line[bracket_start + 1..bracket_end]; - let suffix = &usage_line[bracket_end + 1..]; - - // Split the options by pipe and format them as a list - let formatted_options: Vec = options_str - .split('|') - .map(|opt| format!(" {}", opt)) - .collect(); - - // Build the new usage string - let new_usage = format!( - "{} [OPTIONS] [TASKS]... [-- \ - ...]\n\nOptions:\n{}", - prefix.trim_end(), - formatted_options.join("\n") - ); - - // Replace the old usage line with the new formatted one - err_str.replace_range(usage_start..usage_end, &new_usage); - } - } - } - } - } - + let err_str = format_error_message(e.to_string()); // A cleaner solution would be to implement our own clap::error::ErrorFormatter // but that would require copying the default formatter just to remove this // line: https://docs.rs/clap/latest/src/clap/error/format.rs.html#100 @@ -1539,11 +1538,7 @@ pub async fn run( event.track_call(); let base = CommandBase::new(cli_args.clone(), repo_root, version, color_config)?; event.track_ui_mode(base.opts.run_opts.ui_mode); - if scan::run(base).await { - Ok(0) - } else { - Ok(1) - } + if scan::run(base).await { Ok(0) } else { Ok(1) } } Command::Config => { CommandEventBuilder::new("config") @@ -3199,15 +3194,17 @@ mod test { assert!(Args::try_parse_from(["turbo", "build", "--anon-profile", ""]).is_err()); assert!(Args::try_parse_from(["turbo", "build", "--profile", "foo.json"]).is_ok()); assert!(Args::try_parse_from(["turbo", "build", "--anon-profile", "foo.json"]).is_ok()); - assert!(Args::try_parse_from([ - "turbo", - "build", - "--profile", - "foo.json", - "--anon-profile", - "bar.json" - ]) - .is_err()); + assert!( + Args::try_parse_from([ + "turbo", + "build", + "--profile", + "foo.json", + "--anon-profile", + "bar.json" + ]) + .is_err() + ); } #[test] @@ -3348,19 +3345,23 @@ mod test { .collect(), ) .unwrap(); - assert!(inferred_run - .execution_args - .as_ref() - .is_some_and(|e| e.single_package)); - assert!(explicit_run - .command - .as_ref() - .and_then(|cmd| if let Command::Run { execution_args, .. } = cmd { - Some(execution_args.single_package) - } else { - None - }) - .unwrap_or(false)); + assert!( + inferred_run + .execution_args + .as_ref() + .is_some_and(|e| e.single_package) + ); + assert!( + explicit_run + .command + .as_ref() + .and_then(|cmd| if let Command::Run { execution_args, .. } = cmd { + Some(execution_args.single_package) + } else { + None + }) + .unwrap_or(false) + ); } #[test_case::test_case(&["turbo", "watch", "build", "--no-daemon"]; "after watch")] From ae23fe5704c32c2b39caf4ea71caf6a3eb002e79 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 8 Sep 2025 07:02:44 -0600 Subject: [PATCH 5/6] formatz --- crates/turborepo-lib/src/cli/error.rs | 6 +-- crates/turborepo-lib/src/cli/mod.rs | 71 +++++++++++++-------------- 2 files changed, 37 insertions(+), 40 deletions(-) diff --git a/crates/turborepo-lib/src/cli/error.rs b/crates/turborepo-lib/src/cli/error.rs index 2bdf90c9d3c35..249392352b1f1 100644 --- a/crates/turborepo-lib/src/cli/error.rs +++ b/crates/turborepo-lib/src/cli/error.rs @@ -4,12 +4,12 @@ use itertools::Itertools; use miette::Diagnostic; use thiserror::Error; use turborepo_repository::package_graph; -use turborepo_signals::{listeners::get_signal, SignalHandler}; +use turborepo_signals::{SignalHandler, listeners::get_signal}; use turborepo_telemetry::events::command::CommandEventBuilder; -use turborepo_ui::{color, BOLD, GREY}; +use turborepo_ui::{BOLD, GREY, color}; use crate::{ - commands::{bin, generate, link, login, ls, prune, CommandBase}, + commands::{CommandBase, bin, generate, link, login, ls, prune}, daemon::DaemonError, query, rewrite_json::RewriteError, diff --git a/crates/turborepo-lib/src/cli/mod.rs b/crates/turborepo-lib/src/cli/mod.rs index 4b127ca2c1e53..8d26cd3ea359d 100644 --- a/crates/turborepo-lib/src/cli/mod.rs +++ b/crates/turborepo-lib/src/cli/mod.rs @@ -9,10 +9,10 @@ use std::{ use biome_deserialize_macros::Deserializable; use camino::{Utf8Path, Utf8PathBuf}; use clap::{ - ArgAction, ArgGroup, CommandFactory, Parser, Subcommand, ValueEnum, - builder::NonEmptyStringValueParser, + builder::NonEmptyStringValueParser, ArgAction, ArgGroup, CommandFactory, Parser, Subcommand, + ValueEnum, }; -use clap_complete::{Shell, generate}; +use clap_complete::{generate, Shell}; pub use error::Error; use serde::{Deserialize, Serialize}; use tracing::{debug, error, log::warn}; @@ -20,17 +20,16 @@ use turbopath::AbsoluteSystemPathBuf; use turborepo_api_client::AnonAPIClient; use turborepo_repository::inference::{RepoMode, RepoState}; use turborepo_telemetry::{ - TelemetryHandle, - events::{EventBuilder, EventType, command::CommandEventBuilder, generic::GenericEventBuilder}, - init_telemetry, track_usage, + events::{command::CommandEventBuilder, generic::GenericEventBuilder, EventBuilder, EventType}, + init_telemetry, track_usage, TelemetryHandle, }; use turborepo_ui::{ColorConfig, GREY}; use crate::{ cli::error::print_potential_tasks, commands::{ - CommandBase, bin, boundaries, clone, config, daemon, generate, info, link, login, logout, - ls, prune, query, run, scan, telemetry, unlink, + bin, boundaries, clone, config, daemon, generate, info, link, login, logout, ls, prune, + query, run, scan, telemetry, unlink, CommandBase, }, get_version, run::watch::WatchClient, @@ -1538,7 +1537,11 @@ pub async fn run( event.track_call(); let base = CommandBase::new(cli_args.clone(), repo_root, version, color_config)?; event.track_ui_mode(base.opts.run_opts.ui_mode); - if scan::run(base).await { Ok(0) } else { Ok(1) } + if scan::run(base).await { + Ok(0) + } else { + Ok(1) + } } Command::Config => { CommandEventBuilder::new("config") @@ -3194,17 +3197,15 @@ mod test { assert!(Args::try_parse_from(["turbo", "build", "--anon-profile", ""]).is_err()); assert!(Args::try_parse_from(["turbo", "build", "--profile", "foo.json"]).is_ok()); assert!(Args::try_parse_from(["turbo", "build", "--anon-profile", "foo.json"]).is_ok()); - assert!( - Args::try_parse_from([ - "turbo", - "build", - "--profile", - "foo.json", - "--anon-profile", - "bar.json" - ]) - .is_err() - ); + assert!(Args::try_parse_from([ + "turbo", + "build", + "--profile", + "foo.json", + "--anon-profile", + "bar.json" + ]) + .is_err()); } #[test] @@ -3345,23 +3346,19 @@ mod test { .collect(), ) .unwrap(); - assert!( - inferred_run - .execution_args - .as_ref() - .is_some_and(|e| e.single_package) - ); - assert!( - explicit_run - .command - .as_ref() - .and_then(|cmd| if let Command::Run { execution_args, .. } = cmd { - Some(execution_args.single_package) - } else { - None - }) - .unwrap_or(false) - ); + assert!(inferred_run + .execution_args + .as_ref() + .is_some_and(|e| e.single_package)); + assert!(explicit_run + .command + .as_ref() + .and_then(|cmd| if let Command::Run { execution_args, .. } = cmd { + Some(execution_args.single_package) + } else { + None + }) + .unwrap_or(false)); } #[test_case::test_case(&["turbo", "watch", "build", "--no-daemon"]; "after watch")] From 2b1ab0a69dc30f730dfbbb8ccce3fdb50be74796 Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Mon, 8 Sep 2025 07:03:27 -0600 Subject: [PATCH 6/6] formatz --- crates/turborepo-lib/src/cli/error.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/turborepo-lib/src/cli/error.rs b/crates/turborepo-lib/src/cli/error.rs index 249392352b1f1..2bdf90c9d3c35 100644 --- a/crates/turborepo-lib/src/cli/error.rs +++ b/crates/turborepo-lib/src/cli/error.rs @@ -4,12 +4,12 @@ use itertools::Itertools; use miette::Diagnostic; use thiserror::Error; use turborepo_repository::package_graph; -use turborepo_signals::{SignalHandler, listeners::get_signal}; +use turborepo_signals::{listeners::get_signal, SignalHandler}; use turborepo_telemetry::events::command::CommandEventBuilder; -use turborepo_ui::{BOLD, GREY, color}; +use turborepo_ui::{color, BOLD, GREY}; use crate::{ - commands::{CommandBase, bin, generate, link, login, ls, prune}, + commands::{bin, generate, link, login, ls, prune, CommandBase}, daemon::DaemonError, query, rewrite_json::RewriteError,