diff --git a/buck2_client/src/commands/debug/allocator_stats.rs b/buck2_client/src/commands/debug/allocator_stats.rs index c9df4381ac04b..855490c016de5 100644 --- a/buck2_client/src/commands/debug/allocator_stats.rs +++ b/buck2_client/src/commands/debug/allocator_stats.rs @@ -15,7 +15,6 @@ use crate::commands::streaming::StreamingCommand; use crate::common::CommonBuildConfigurationOptions; use crate::common::CommonConsoleOptions; use crate::common::CommonDaemonCommandOptions; -use crate::common::ConsoleType; use crate::daemon::client::connect::BuckdConnectOptions; use crate::daemon::client::BuckdClientConnector; use crate::exit_result::ExitResult; @@ -59,11 +58,7 @@ impl StreamingCommand for AllocatorStatsCommand { } fn console_opts(&self) -> &CommonConsoleOptions { - static OPTS: CommonConsoleOptions = CommonConsoleOptions { - console_type: ConsoleType::None, - ui: vec![], - }; - &OPTS + CommonConsoleOptions::none_ref() } fn event_log_opts(&self) -> &CommonDaemonCommandOptions { diff --git a/buck2_client/src/commands/debug/crash.rs b/buck2_client/src/commands/debug/crash.rs index f2602442c2740..c2bd71ec98879 100644 --- a/buck2_client/src/commands/debug/crash.rs +++ b/buck2_client/src/commands/debug/crash.rs @@ -15,7 +15,6 @@ use crate::commands::streaming::StreamingCommand; use crate::common::CommonBuildConfigurationOptions; use crate::common::CommonConsoleOptions; use crate::common::CommonDaemonCommandOptions; -use crate::common::ConsoleType; use crate::daemon::client::connect::BuckdConnectOptions; use crate::daemon::client::BuckdClientConnector; use crate::exit_result::ExitResult; @@ -48,11 +47,7 @@ impl StreamingCommand for CrashCommand { } fn console_opts(&self) -> &CommonConsoleOptions { - static OPTS: CommonConsoleOptions = CommonConsoleOptions { - console_type: ConsoleType::Simple, - ui: vec![], - }; - &OPTS + CommonConsoleOptions::simple_ref() } fn event_log_opts(&self) -> &CommonDaemonCommandOptions { diff --git a/buck2_client/src/commands/debug/dice_dump.rs b/buck2_client/src/commands/debug/dice_dump.rs index 19d02cb97d941..0fbf1f8318562 100644 --- a/buck2_client/src/commands/debug/dice_dump.rs +++ b/buck2_client/src/commands/debug/dice_dump.rs @@ -16,7 +16,6 @@ use crate::commands::streaming::StreamingCommand; use crate::common::CommonBuildConfigurationOptions; use crate::common::CommonConsoleOptions; use crate::common::CommonDaemonCommandOptions; -use crate::common::ConsoleType; use crate::daemon::client::connect::BuckdConnectOptions; use crate::daemon::client::BuckdClientConnector; use crate::exit_result::ExitResult; @@ -63,11 +62,7 @@ impl StreamingCommand for DiceDumpCommand { } fn console_opts(&self) -> &CommonConsoleOptions { - static OPTS: CommonConsoleOptions = CommonConsoleOptions { - console_type: ConsoleType::None, - ui: vec![], - }; - &OPTS + CommonConsoleOptions::none_ref() } fn event_log_opts(&self) -> &CommonDaemonCommandOptions { diff --git a/buck2_client/src/commands/debug/flush_dep_files.rs b/buck2_client/src/commands/debug/flush_dep_files.rs index eb7662dc1afda..5146dc5ca4b0d 100644 --- a/buck2_client/src/commands/debug/flush_dep_files.rs +++ b/buck2_client/src/commands/debug/flush_dep_files.rs @@ -15,7 +15,6 @@ use crate::commands::streaming::StreamingCommand; use crate::common::CommonBuildConfigurationOptions; use crate::common::CommonConsoleOptions; use crate::common::CommonDaemonCommandOptions; -use crate::common::ConsoleType; use crate::daemon::client::connect::BuckdConnectOptions; use crate::daemon::client::BuckdClientConnector; use crate::exit_result::ExitResult; @@ -48,11 +47,7 @@ impl StreamingCommand for FlushDepFilesCommand { } fn console_opts(&self) -> &CommonConsoleOptions { - static OPTS: CommonConsoleOptions = CommonConsoleOptions { - console_type: ConsoleType::Simple, - ui: vec![], - }; - &OPTS + CommonConsoleOptions::simple_ref() } fn event_log_opts(&self) -> &CommonDaemonCommandOptions { diff --git a/buck2_client/src/commands/debug/heap_dump.rs b/buck2_client/src/commands/debug/heap_dump.rs index c0bef527cc18f..4316d0db2aea5 100644 --- a/buck2_client/src/commands/debug/heap_dump.rs +++ b/buck2_client/src/commands/debug/heap_dump.rs @@ -15,7 +15,6 @@ use crate::commands::streaming::StreamingCommand; use crate::common::CommonBuildConfigurationOptions; use crate::common::CommonConsoleOptions; use crate::common::CommonDaemonCommandOptions; -use crate::common::ConsoleType; use crate::daemon::client::connect::BuckdConnectOptions; use crate::daemon::client::BuckdClientConnector; use crate::exit_result::ExitResult; @@ -54,11 +53,7 @@ impl StreamingCommand for HeapDumpCommand { } fn console_opts(&self) -> &CommonConsoleOptions { - static OPTS: CommonConsoleOptions = CommonConsoleOptions { - console_type: ConsoleType::None, - ui: vec![], - }; - &OPTS + CommonConsoleOptions::none_ref() } fn event_log_opts(&self) -> &CommonDaemonCommandOptions { diff --git a/buck2_client/src/commands/rage.rs b/buck2_client/src/commands/rage.rs index 89d9073f388ff..e08ceb010b598 100644 --- a/buck2_client/src/commands/rage.rs +++ b/buck2_client/src/commands/rage.rs @@ -34,7 +34,6 @@ use crate::commands::streaming::StreamingCommand; use crate::common::CommonBuildConfigurationOptions; use crate::common::CommonConsoleOptions; use crate::common::CommonDaemonCommandOptions; -use crate::common::ConsoleType; use crate::daemon::client::connect::BuckdConnectOptions; use crate::daemon::client::BuckdClientConnector; use crate::exit_result::ExitResult; @@ -168,11 +167,7 @@ impl StreamingCommand for RageCommand { } fn console_opts(&self) -> &CommonConsoleOptions { - static OPTS: CommonConsoleOptions = CommonConsoleOptions { - console_type: ConsoleType::Simple, - ui: vec![], - }; - &OPTS + CommonConsoleOptions::simple_ref() } fn event_log_opts(&self) -> &CommonDaemonCommandOptions { diff --git a/buck2_client/src/commands/server.rs b/buck2_client/src/commands/server.rs index 517b7a0f0c449..d0fd41a3d7525 100644 --- a/buck2_client/src/commands/server.rs +++ b/buck2_client/src/commands/server.rs @@ -15,7 +15,6 @@ use crate::commands::streaming::StreamingCommand; use crate::common::CommonBuildConfigurationOptions; use crate::common::CommonConsoleOptions; use crate::common::CommonDaemonCommandOptions; -use crate::common::ConsoleType; use crate::daemon::client::BuckdClientConnector; use crate::exit_result::ExitResult; @@ -39,11 +38,7 @@ impl StreamingCommand for ServerCommand { } fn console_opts(&self) -> &CommonConsoleOptions { - static OPTS: CommonConsoleOptions = CommonConsoleOptions { - console_type: ConsoleType::Simple, - ui: vec![], - }; - &OPTS + CommonConsoleOptions::simple_ref() } fn event_log_opts(&self) -> &CommonDaemonCommandOptions { diff --git a/buck2_client/src/common.rs b/buck2_client/src/common.rs index 52080f0539c83..dcf1bde91c739 100644 --- a/buck2_client/src/common.rs +++ b/buck2_client/src/common.rs @@ -401,6 +401,23 @@ impl CommonConsoleOptions { }; &OPTS } + + pub fn simple_ref() -> &'static Self { + static OPTS: CommonConsoleOptions = CommonConsoleOptions { + console_type: ConsoleType::Simple, + ui: vec![], + }; + &OPTS + } + + pub fn none_ref() -> &'static Self { + static OPTS: CommonConsoleOptions = CommonConsoleOptions { + console_type: ConsoleType::None, + ui: vec![], + }; + &OPTS + } + pub fn final_console(&self) -> FinalConsole { let is_tty = match self.console_type { ConsoleType::Auto | ConsoleType::Simple => std::io::stderr().is_tty(),