Skip to content

Commit 414bc0a

Browse files
committed
fix(cli): address policy get json clippy
1 parent 503dc1a commit 414bc0a

2 files changed

Lines changed: 26 additions & 14 deletions

File tree

crates/openshell-cli/src/run.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5656,32 +5656,46 @@ pub async fn sandbox_policy_get(
56565656
output: &str,
56575657
tls: &TlsOptions,
56585658
) -> Result<()> {
5659-
let mut stdout = std::io::stdout().lock();
5660-
let mut stderr = std::io::stderr().lock();
5659+
let mut stdout = Vec::new();
5660+
let mut stderr = Vec::new();
56615661
sandbox_policy_get_to_writer(
56625662
server,
56635663
name,
56645664
version,
56655665
full,
56665666
output,
56675667
tls,
5668-
&mut stdout,
5669-
&mut stderr,
5668+
(&mut stdout, &mut stderr),
56705669
)
5671-
.await
5670+
.await?;
5671+
5672+
{
5673+
let mut terminal_stdout = std::io::stdout().lock();
5674+
terminal_stdout.write_all(&stdout).into_diagnostic()?;
5675+
}
5676+
{
5677+
let mut terminal_stderr = std::io::stderr().lock();
5678+
terminal_stderr.write_all(&stderr).into_diagnostic()?;
5679+
}
5680+
5681+
Ok(())
56725682
}
56735683

56745684
#[doc(hidden)]
5675-
pub async fn sandbox_policy_get_to_writer<W: Write, E: Write>(
5685+
pub async fn sandbox_policy_get_to_writer<W, E>(
56765686
server: &str,
56775687
name: &str,
56785688
version: u32,
56795689
full: bool,
56805690
output: &str,
56815691
tls: &TlsOptions,
5682-
stdout: &mut W,
5683-
stderr: &mut E,
5684-
) -> Result<()> {
5692+
writers: (&mut W, &mut E),
5693+
) -> Result<()>
5694+
where
5695+
W: Write + Send,
5696+
E: Write + Send,
5697+
{
5698+
let (stdout, stderr) = writers;
56855699
let mut client = grpc_client(server, tls).await?;
56865700

56875701
let status_resp = client

crates/openshell-cli/tests/sandbox_name_fallback_integration.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl OpenShell for TestOpenShell {
323323

324324
let policy = SandboxPolicy {
325325
version: 7,
326-
network_policies: [(
326+
network_policies: std::iter::once((
327327
"api".to_string(),
328328
NetworkPolicyRule {
329329
name: "api".to_string(),
@@ -337,8 +337,7 @@ impl OpenShell for TestOpenShell {
337337
}],
338338
..Default::default()
339339
},
340-
)]
341-
.into_iter()
340+
))
342341
.collect(),
343342
..Default::default()
344343
};
@@ -610,8 +609,7 @@ async fn policy_get_full_json_cli_prints_policy_payload() {
610609
true,
611610
"json",
612611
&ts.tls,
613-
&mut stdout,
614-
&mut stderr,
612+
(&mut stdout, &mut stderr),
615613
)
616614
.await
617615
.expect("policy get should succeed");

0 commit comments

Comments
 (0)