Skip to content

Commit

Permalink
buck2: stdin: take console opts when creating interactive stream
Browse files Browse the repository at this point in the history
Summary: To allow disabling this if needed.

Reviewed By: IanChilds

Differential Revision: D39810490

fbshipit-source-id: f0138fd0f76eded825c644b87e45cef3b83a9a3c
  • Loading branch information
krallin authored and facebook-github-bot committed Sep 26, 2022
1 parent f72ed01 commit 84b4fb7
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion buck2_audit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl StreamingCommand for AuditCommand {
context: Some(context),
serialized_opts: serialized,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(self.console_opts()),
)
.await??;
ExitResult::success()
Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/aquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl StreamingCommand for AqueryCommand {
output_attributes,
unstable_output_format,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await??;

Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl StreamingCommand for BuildCommand {
build_opts: Some(self.build_opts.to_proto()),
final_artifact_materializations: self.materializations.to_proto() as i32,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await;
let success = match &result {
Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/bxl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl StreamingCommand for BxlCommand {
build_opts: Some(self.build_opts.to_proto()),
final_artifact_materializations: self.materializations.to_proto() as i32,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await;
let success = match &result {
Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/cquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl StreamingCommand for CqueryCommand {
target_call_stacks: self.query_common.target_call_stacks,
correct_owner,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await??;

Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/debug/materialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ impl StreamingCommand for MaterializeCommand {
context: Some(context),
paths: self.paths,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await??;

Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl StreamingCommand for InstallCommand {
build_opts: Some(self.build_opts.to_proto()),
installer_run_args: self.extra_run_args,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await;
let console = self.console_opts.final_console();
Expand Down
3 changes: 2 additions & 1 deletion buck2_client/src/commands/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ impl StreamingCommand for ProfileSubcommand {
action: self.action.into(),
recursive: self.opts.recursive,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin()
.console_interaction_stream(&self.opts.console_opts),
)
.await??;
let ProfileResponse {
Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl StreamingCommand for RunCommand {
build_opts: Some(self.build_opts.to_proto()),
final_artifact_materializations: Materializations::Materialize as i32,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await;

Expand Down
17 changes: 13 additions & 4 deletions buck2_client/src/commands/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,18 +225,19 @@ impl StreamingCommand for TargetsCommand {
};

if self.show_output {
targets_show_outputs(ctx.stdin(), buckd, target_request, None).await
targets_show_outputs(ctx.stdin(), buckd, target_request, None, &self.console_opts).await
} else if self.show_full_output {
let project_root = ctx.paths()?.roots.project_root.clone();
targets_show_outputs(
ctx.stdin(),
buckd,
target_request,
Some(project_root.root()),
&self.console_opts,
)
.await
} else {
targets(ctx.stdin(), buckd, target_request).await
targets(ctx.stdin(), buckd, target_request, &self.console_opts).await
}
}

Expand All @@ -258,10 +259,14 @@ async fn targets_show_outputs(
mut buckd: BuckdClientConnector,
target_request: TargetsRequest,
root_path: Option<&AbsPath>,
console_opts: &CommonConsoleOptions,
) -> ExitResult {
let response = buckd
.with_flushing()
.targets_show_outputs(target_request, stdin.console_interaction_stream())
.targets_show_outputs(
target_request,
stdin.console_interaction_stream(console_opts),
)
.await??;
for target_paths in response.targets_paths {
for path in target_paths.paths {
Expand Down Expand Up @@ -289,10 +294,14 @@ async fn targets(
stdin: &mut Stdin,
mut buckd: BuckdClientConnector,
target_request: TargetsRequest,
console_opts: &CommonConsoleOptions,
) -> ExitResult {
let response = buckd
.with_flushing()
.targets(target_request, stdin.console_interaction_stream())
.targets(
target_request,
stdin.console_interaction_stream(console_opts),
)
.await??;
if !response.serialized_targets_output.is_empty() {
crate::print!("{}", response.serialized_targets_output)?;
Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl StreamingCommand for TestCommand {
force_run_from_project_root: self.unstable_force_tests_on_re,
}),
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await??;

Expand Down
2 changes: 1 addition & 1 deletion buck2_client/src/commands/uquery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl StreamingCommand for UqueryCommand {
unstable_output_format,
target_call_stacks: self.query_common.target_call_stacks,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await??;

Expand Down
6 changes: 5 additions & 1 deletion buck2_client/src/stdin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
use tokio_util::io::StreamReader;

use crate::common::CommonConsoleOptions;
use crate::console_interaction_stream::ConsoleInteractionStream;

#[pin_project]
Expand Down Expand Up @@ -99,7 +100,10 @@ impl Stdin {
)
}

pub fn console_interaction_stream(&mut self) -> Option<ConsoleInteractionStream<'_>> {
pub fn console_interaction_stream(
&mut self,
_opts: &CommonConsoleOptions,
) -> Option<ConsoleInteractionStream<'_>> {
ConsoleInteractionStream::new(self)
}
}
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/docs/starlark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl StreamingCommand for DocsStarlarkCommand {
retrieve_builtins: self.builtins,
retrieve_prelude: self.prelude,
},
ctx.stdin().console_interaction_stream(),
ctx.stdin().console_interaction_stream(&self.console_opts),
)
.await??;

Expand Down

0 comments on commit 84b4fb7

Please sign in to comment.