From 9c7a7656ae82bd6dfa6dadfb97d8b7ce871f7d0c Mon Sep 17 00:00:00 2001 From: Thomas Orozco Date: Mon, 26 Sep 2022 07:01:35 -0700 Subject: [PATCH] buck2: allow disabling interactive console Summary: Like it says in the title. Context: https://fb.workplace.com/groups/buck2eng/permalink/2999998796964267/ Reviewed By: IanChilds Differential Revision: D39810489 fbshipit-source-id: d122b1a5ccce4c7494d482c9378e40d2db8689cf --- buck2_client/src/commands/lsp.rs | 1 + buck2_client/src/common.rs | 11 +++++++++++ buck2_client/src/stdin.rs | 7 ++++++- 3 files changed, 18 insertions(+), 1 deletion(-) 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) } }