Skip to content

Commit

Permalink
buck2: allow disabling interactive console
Browse files Browse the repository at this point in the history
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
  • Loading branch information
krallin authored and facebook-github-bot committed Sep 26, 2022
1 parent 84b4fb7 commit 9c7a765
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions buck2_client/src/commands/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl StreamingCommand for LspCommand {
static SIMPLE_CONSOLE: Lazy<CommonConsoleOptions> = Lazy::new(|| CommonConsoleOptions {
console_type: ConsoleType::Simple,
ui: vec![],
no_interactive_console: true,
});
&SIMPLE_CONSOLE
}
Expand Down
11 changes: 11 additions & 0 deletions buck2_client/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,21 @@ pub struct CommonConsoleOptions {
arg_enum
)]
pub ui: Vec<UiOptions>,

#[clap(
long,
help = "Disable console interactions",
env = "BUCK_NO_INTERACTIVE_CONSOLE"
)]
pub no_interactive_console: bool,
}

impl Default for CommonConsoleOptions {
fn default() -> Self {
Self {
console_type: ConsoleType::Auto,
ui: Vec::new(),
no_interactive_console: false,
}
}
}
Expand All @@ -398,6 +406,7 @@ impl CommonConsoleOptions {
static OPTS: CommonConsoleOptions = CommonConsoleOptions {
console_type: ConsoleType::Auto,
ui: vec![],
no_interactive_console: false,
};
&OPTS
}
Expand All @@ -406,6 +415,7 @@ impl CommonConsoleOptions {
static OPTS: CommonConsoleOptions = CommonConsoleOptions {
console_type: ConsoleType::Simple,
ui: vec![],
no_interactive_console: false,
};
&OPTS
}
Expand All @@ -414,6 +424,7 @@ impl CommonConsoleOptions {
static OPTS: CommonConsoleOptions = CommonConsoleOptions {
console_type: ConsoleType::None,
ui: vec![],
no_interactive_console: false,
};
&OPTS
}
Expand Down
7 changes: 6 additions & 1 deletion buck2_client/src/stdin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ impl Stdin {

pub fn console_interaction_stream(
&mut self,
_opts: &CommonConsoleOptions,
opts: &CommonConsoleOptions,
) -> Option<ConsoleInteractionStream<'_>> {
if opts.no_interactive_console {
tracing::debug!("Disabling console interaction: no_interactive_console is set");
return None;
}

ConsoleInteractionStream::new(self)
}
}
Expand Down

0 comments on commit 9c7a765

Please sign in to comment.