From 105aa636180c02a8154907ca2b5c6b35c34cfdf8 Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Fri, 6 Jan 2023 16:14:28 -0800 Subject: [PATCH] ui: field not required, and defaults to title --- src/main.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index fa97280..8f785dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,7 +35,6 @@ struct CliArgs { /// The value used to search/switch tracks #[arg( index = 2, - requires("field"), required_if_eq_any([("action", "search"), ("action", "SwitchTo")]) )] search_arg: Option, @@ -46,10 +45,10 @@ 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"]) + default_value = "title", + value_parser(["title", "artist", "album"]), )] - field: Option, + field: String, // Add flag for "search filepaths too" } @@ -66,7 +65,7 @@ fn main() { SousaCommands::Play => serde_json::to_string(&UIRequest::Play).unwrap(), SousaCommands::Pause => serde_json::to_string(&UIRequest::Pause).unwrap(), SousaCommands::Search => { - let request = match parse_to_partialtag(cli.field.unwrap(), cli.search_arg.unwrap()) { + let request = match parse_to_partialtag(cli.field, cli.search_arg.unwrap()) { Ok(tag) => UIRequest::Search(tag), Err(_) => panic!( "Unknown Search type! Expected values are 'title', 'artist', and 'album'" @@ -75,7 +74,7 @@ fn main() { serde_json::to_string(&request).unwrap() } SousaCommands::SwitchTo => { - let request = match parse_to_partialtag(cli.field.unwrap(), cli.search_arg.unwrap()) { + let request = match parse_to_partialtag(cli.field, cli.search_arg.unwrap()) { Ok(tag) => UIRequest::SwitchTo(tag), Err(_) => panic!("Unknown type!"), };