Skip to content

Commit

Permalink
feat: add del command
Browse files Browse the repository at this point in the history
Relates to #16
  • Loading branch information
johnallen3d committed Sep 17, 2023
1 parent 4186492 commit dfc897a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ pub(crate) enum Commands {
/// Print the current song
#[command()]
Current,
/// Print the current song
#[command()]
Del { position: Option<u32> },

//
// playback related commands
Expand Down
14 changes: 14 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,20 @@ impl Client {
self.current_status()
}

pub fn del(
&mut self,
position: Option<u32>,
) -> eyre::Result<Option<String>> {
let postion = match position {
Some(position) => position,
None => self.status()?.position,
};

self.client.delete(postion)?;

self.current_status()
}

//
// playback related commands
//
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fn main() {

let result = match args.command {
Some(Commands::Crop) => mpd.crop(),
Some(Commands::Del { position }) => mpd.del(position),
Some(Commands::Current) => mpd.current(),
Some(Commands::Play) => mpd.play(),
Some(Commands::Next) => mpd.next(),
Expand Down

0 comments on commit dfc897a

Please sign in to comment.