Skip to content

Commit

Permalink
feat: add outputset command
Browse files Browse the repository at this point in the history
Relates to #16
  • Loading branch information
johnallen3d committed Sep 24, 2023
1 parent 509a1b8 commit 00b26e1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ pub(crate) enum Commands {
/// example: `mp-cli toggleoutput <output # or name> [...]`
#[command()]
Toggleoutput { args: Vec<String> },
/// Set attributes of the given output.
/// example: `mp-cli outputset <output # or name> <name>=<value>`
#[command()]
Outputset { args: Vec<String> },
/// Display the next song in the queue
#[command()]
Queued,
Expand Down
17 changes: 17 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,23 @@ impl Client {
self.outputs()
}

pub fn output_set(
&mut self,
mut args: Vec<String>,
) -> eyre::Result<Option<String>> {
if args.is_empty() {
return Err(eyre::eyre!("no outputs given"));
}

let name_or_id = args.pop().ok_or(eyre::eyre!("no outputs given"))?;
let output = self.output_for(&name_or_id)?;

// TODO: this doesn't appear to be available in rust-mpd
// self.client.out_set(id)

Ok(None)
}

pub fn queued(&mut self) -> eyre::Result<Option<String>> {
if let Some(song) =
self.client.queue().map_err(|e| eyre::eyre!(e))?.get(0)
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ fn main() {
Some(Commands::Enable { args }) => mpd.enable(args),
Some(Commands::Disable { args }) => mpd.disable(args),
Some(Commands::Toggleoutput { args }) => mpd.toggle_output(args),
Some(Commands::Outputset { args }) => mpd.output_set(args),
Some(Commands::Queued) => mpd.queued(),
Some(Commands::Shuffle) => mpd.shuffle(),
Some(Commands::Lsplaylists) => mpd.lsplaylists(),
Expand Down

0 comments on commit 00b26e1

Please sign in to comment.