add --[-no]-clear-query-onl-play flags

This commit is contained in:
figsoda 2020-11-09 16:28:23 -05:00
parent 1f2974f89f
commit 2b3d0799a7
2 changed files with 17 additions and 1 deletions

View file

@ -43,7 +43,9 @@ mmtc [FLAGS] [OPTIONS]
flag | description
-|-
--cycle | Cycle through the queue
--clear-query-on-play | Clear query on play
-h, --help | Prints help information
--no-clear-query-on-play | Don't clear query on play
--no-cycle | Don't cycle through the queue
-V, --version | Prints version information

View file

@ -53,6 +53,10 @@ struct Opts {
#[structopt(long, value_name = "address")]
address: Option<String>,
/// Clear query on play
#[structopt(long)]
clear_query_on_play: bool,
/// Cycle through the queue
#[structopt(long)]
cycle: bool,
@ -61,6 +65,10 @@ struct Opts {
#[structopt(long, value_name = "number")]
jump_lines: Option<usize>,
/// Don't clear query on play
#[structopt(long, overrides_with("clear_query_on_play"))]
no_clear_query_on_play: bool,
/// Don't cycle through the queue
#[structopt(long, overrides_with("cycle"))]
no_cycle: bool,
@ -151,6 +159,12 @@ async fn run() -> Result<()> {
} else {
cfg.address
};
let clear_query_on_play = opts.clear_query_on_play
|| if opts.no_clear_query_on_play {
false
} else {
cfg.clear_query_on_play
};
let cycle = opts.cycle || if opts.no_cycle { false } else { cfg.cycle };
let jump_lines = opts.jump_lines.unwrap_or(cfg.jump_lines);
let seek_secs = opts.seek_secs.unwrap_or(cfg.seek_secs);
@ -432,7 +446,7 @@ async fn run() -> Result<()> {
.context("Failed to play the selected song")?;
};
tx.send(Command::UpdateStatus).await?;
if cfg.clear_query_on_play {
if clear_query_on_play {
tx.send(Command::ClearQuery).await?;
}
tx.send(Command::UpdateFrame).await?;