Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(cli): address policy get json clippy
  • Loading branch information
johntmyers committed May 22, 2026
commit fefbca993494efe89f49229feba41f33a23a4ea6
32 changes: 23 additions & 9 deletions crates/openshell-cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6128,32 +6128,46 @@ pub async fn sandbox_policy_get(
output: &str,
tls: &TlsOptions,
) -> Result<()> {
let mut stdout = std::io::stdout().lock();
let mut stderr = std::io::stderr().lock();
let mut stdout = Vec::new();
let mut stderr = Vec::new();
sandbox_policy_get_to_writer(
server,
name,
version,
full,
output,
tls,
&mut stdout,
&mut stderr,
(&mut stdout, &mut stderr),
)
.await
.await?;

{
let mut terminal_stdout = std::io::stdout().lock();
terminal_stdout.write_all(&stdout).into_diagnostic()?;
}
{
let mut terminal_stderr = std::io::stderr().lock();
terminal_stderr.write_all(&stderr).into_diagnostic()?;
}

Ok(())
}

#[doc(hidden)]
pub async fn sandbox_policy_get_to_writer<W: Write, E: Write>(
pub async fn sandbox_policy_get_to_writer<W, E>(
server: &str,
name: &str,
version: u32,
full: bool,
output: &str,
tls: &TlsOptions,
stdout: &mut W,
stderr: &mut E,
) -> Result<()> {
writers: (&mut W, &mut E),
) -> Result<()>
where
W: Write + Send,
E: Write + Send,
{
let (stdout, stderr) = writers;
let mut client = grpc_client(server, tls).await?;

let status_resp = client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl OpenShell for TestOpenShell {

let policy = SandboxPolicy {
version: 7,
network_policies: [(
network_policies: std::iter::once((
"api".to_string(),
NetworkPolicyRule {
name: "api".to_string(),
Expand All @@ -365,8 +365,7 @@ impl OpenShell for TestOpenShell {
}],
..Default::default()
},
)]
.into_iter()
))
.collect(),
..Default::default()
};
Expand Down Expand Up @@ -652,8 +651,7 @@ async fn policy_get_full_json_cli_prints_policy_payload() {
true,
"json",
&ts.tls,
&mut stdout,
&mut stderr,
(&mut stdout, &mut stderr),
)
.await
.expect("policy get should succeed");
Expand Down
Loading