mirror of
https://github.com/figsoda/mmtc
synced 2024-11-10 10:14:13 +00:00
add --[-no]-clear-query-onl-play flags
This commit is contained in:
parent
1f2974f89f
commit
2b3d0799a7
2 changed files with 17 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -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?;
|
||||
|
|
Loading…
Reference in a new issue