diff --git a/buck2_client/src/commands/lsp.rs b/buck2_client/src/commands/lsp.rs index 65856d326b53b..843d31bdec675 100644 --- a/buck2_client/src/commands/lsp.rs +++ b/buck2_client/src/commands/lsp.rs @@ -82,6 +82,7 @@ impl StreamingCommand for LspCommand { static SIMPLE_CONSOLE: Lazy = Lazy::new(|| CommonConsoleOptions { console_type: ConsoleType::Simple, ui: vec![], + no_interactive_console: true, }); &SIMPLE_CONSOLE } diff --git a/buck2_client/src/common.rs b/buck2_client/src/common.rs index dcf1bde91c739..6ac480c8269ab 100644 --- a/buck2_client/src/common.rs +++ b/buck2_client/src/common.rs @@ -382,6 +382,13 @@ pub struct CommonConsoleOptions { arg_enum )] pub ui: Vec, + + #[clap( + long, + help = "Disable console interactions", + env = "BUCK_NO_INTERACTIVE_CONSOLE" + )] + pub no_interactive_console: bool, } impl Default for CommonConsoleOptions { @@ -389,6 +396,7 @@ impl Default for CommonConsoleOptions { Self { console_type: ConsoleType::Auto, ui: Vec::new(), + no_interactive_console: false, } } } @@ -398,6 +406,7 @@ impl CommonConsoleOptions { static OPTS: CommonConsoleOptions = CommonConsoleOptions { console_type: ConsoleType::Auto, ui: vec![], + no_interactive_console: false, }; &OPTS } @@ -406,6 +415,7 @@ impl CommonConsoleOptions { static OPTS: CommonConsoleOptions = CommonConsoleOptions { console_type: ConsoleType::Simple, ui: vec![], + no_interactive_console: false, }; &OPTS } @@ -414,6 +424,7 @@ impl CommonConsoleOptions { static OPTS: CommonConsoleOptions = CommonConsoleOptions { console_type: ConsoleType::None, ui: vec![], + no_interactive_console: false, }; &OPTS } diff --git a/buck2_client/src/stdin.rs b/buck2_client/src/stdin.rs index 4dcf322ba8dd3..e2c9dcdc2e915 100644 --- a/buck2_client/src/stdin.rs +++ b/buck2_client/src/stdin.rs @@ -102,8 +102,13 @@ impl Stdin { pub fn console_interaction_stream( &mut self, - _opts: &CommonConsoleOptions, + opts: &CommonConsoleOptions, ) -> Option> { + if opts.no_interactive_console { + tracing::debug!("Disabling console interaction: no_interactive_console is set"); + return None; + } + ConsoleInteractionStream::new(self) } }