ui: field not required, and defaults to title
This commit is contained in:
parent
b9b733f271
commit
105aa63618
1 changed files with 5 additions and 6 deletions
11
src/main.rs
11
src/main.rs
|
@ -35,7 +35,6 @@ struct CliArgs {
|
||||||
/// The value used to search/switch tracks
|
/// The value used to search/switch tracks
|
||||||
#[arg(
|
#[arg(
|
||||||
index = 2,
|
index = 2,
|
||||||
requires("field"),
|
|
||||||
required_if_eq_any([("action", "search"), ("action", "SwitchTo")])
|
required_if_eq_any([("action", "search"), ("action", "SwitchTo")])
|
||||||
)]
|
)]
|
||||||
search_arg: Option<String>,
|
search_arg: Option<String>,
|
||||||
|
@ -46,10 +45,10 @@ struct CliArgs {
|
||||||
/// The field to search for when running `search`
|
/// The field to search for when running `search`
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
required_if_eq_any([("action", "search"), ("action", "SwitchTo")]),
|
default_value = "title",
|
||||||
value_parser(["title", "artist", "album"])
|
value_parser(["title", "artist", "album"]),
|
||||||
)]
|
)]
|
||||||
field: Option<String>,
|
field: String,
|
||||||
// Add flag for "search filepaths too"
|
// Add flag for "search filepaths too"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +65,7 @@ fn main() {
|
||||||
SousaCommands::Play => serde_json::to_string(&UIRequest::Play).unwrap(),
|
SousaCommands::Play => serde_json::to_string(&UIRequest::Play).unwrap(),
|
||||||
SousaCommands::Pause => serde_json::to_string(&UIRequest::Pause).unwrap(),
|
SousaCommands::Pause => serde_json::to_string(&UIRequest::Pause).unwrap(),
|
||||||
SousaCommands::Search => {
|
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),
|
Ok(tag) => UIRequest::Search(tag),
|
||||||
Err(_) => panic!(
|
Err(_) => panic!(
|
||||||
"Unknown Search type! Expected values are 'title', 'artist', and 'album'"
|
"Unknown Search type! Expected values are 'title', 'artist', and 'album'"
|
||||||
|
@ -75,7 +74,7 @@ fn main() {
|
||||||
serde_json::to_string(&request).unwrap()
|
serde_json::to_string(&request).unwrap()
|
||||||
}
|
}
|
||||||
SousaCommands::SwitchTo => {
|
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),
|
Ok(tag) => UIRequest::SwitchTo(tag),
|
||||||
Err(_) => panic!("Unknown type!"),
|
Err(_) => panic!("Unknown type!"),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue