From fea482479a75a16e9f6e33d4c96e4f5d5aad2ab7 Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Fri, 23 Dec 2022 15:07:46 -0800 Subject: [PATCH] cli: now prints response message --- src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 96079e1..019e6a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,7 @@ struct CliArgs { port: Option, /// The command to execute - #[arg(index = 1, value_enum, requires("search_arg"))] + #[arg(index = 1, value_enum)] action: Option, /// The string to search for when paired with a "Search" action @@ -38,6 +38,7 @@ struct CliArgs { /// The field to search for when running `search` #[arg( long, + required_if_eq_any([("action", "search"), ("action", "SwitchTo")]), value_parser(["title", "artist", "album"]) )] field: Option, @@ -78,7 +79,11 @@ fn main() { let msg = socket.read_message().expect("Error reading message"); let resp: message_types::ServerResponse = serde_json::from_str(msg.into_text().unwrap().as_str()).unwrap(); - resp.pretty_print(); + println!("\n{}\n", resp.message); + + if resp.search_results.len() > 0 { + resp.pretty_print(); + } //println!("recieved: {:?}\n{:?}", resp.message, resp.search_results); socket.close(None).unwrap(); }