From 9fad2551004d3e0da3b43790c53af96b66ef507f Mon Sep 17 00:00:00 2001 From: Jarrod Overson Date: Wed, 18 Oct 2023 05:58:36 -0400 Subject: [PATCH] fix: re-hooked up --values arg, fixes #456 --- src/utils.rs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index eaa08ecf..c3ff8586 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -172,7 +172,7 @@ pub(crate) async fn print_stream_json( mut stream: PacketStream, filter: &[String], - _terse: bool, + terse: bool, raw: bool, ) -> Result<()> { if !filter.is_empty() { @@ -181,15 +181,34 @@ pub(crate) async fn print_stream_json( while let Some(packet) = stream.next().await { match packet { Ok(packet) => { - if (packet.is_done()) && !raw { + if (packet.is_signal()) && !raw { continue; } if !filter.is_empty() && !filter.iter().any(|name| name == packet.port()) { tracing::debug!(port = %packet.port(), "cli:output:filtering"); continue; } - let json = packet.to_json(); - println!("{}", json); + if terse { + match packet.payload { + wick_packet::PacketPayload::Ok(_) => { + let value = packet.decode_value()?; + match value { + Value::String(s) => { + println!("{}", s); + } + _ => { + println!("{}", value); + } + } + } + wick_packet::PacketPayload::Err(e) => { + anyhow::bail!("{}", e); + } + } + } else { + let json = packet.to_json(); + println!("{}", json); + } } Err(e) => { error!(error = %e, "cli:output:error");