• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

johnallen3d / mpc-rs / #110

23 Sep 2023 01:18AM UTC coverage: 0.0%. Remained the same
#110

push

johnallen3d
feat: add `add` command

Relates to #16

13 of 13 new or added lines in 2 files covered. (100.0%)

0 of 376 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main.rs
1
#![deny(clippy::pedantic)]
2
extern crate chrono;
3
extern crate mpd;
4
extern crate serde_json;
5

6
use clap::Parser;
7

8
mod args;
9
mod client;
10
mod se;
11

12
use args::{Cli, Commands};
13

14
fn main() {
×
15
    let args = Cli::parse();
×
16

17
    // safe to unwrap because we have default values
18
    let mut mpd = match crate::client::Client::new(
×
19
        &args.bind_to_address.unwrap(),
×
20
        &args.port.unwrap(),
×
21
        args.format.clone(),
×
22
    ) {
23
        Ok(client) => client,
×
24
        Err(e) => handle_error(e),
×
25
    };
26

27
    let result = match args.command {
×
28
        Some(Commands::Add { path }) => mpd.add(&path),
×
29
        Some(Commands::Crop) => mpd.crop(),
×
30
        Some(Commands::Del { position }) => mpd.del(position),
×
31
        Some(Commands::Current) => mpd.current(),
×
32
        Some(Commands::Play { position }) => mpd.play(position),
×
33
        Some(Commands::Next) => mpd.next(),
×
34
        Some(Commands::Prev) => mpd.prev(),
×
35
        Some(Commands::Pause) => mpd.pause(),
×
36
        Some(Commands::PauseIfPlaying) => mpd.pause_if_playing(),
×
37
        Some(Commands::Toggle) => mpd.toggle(),
×
38
        Some(Commands::Cdprev) => mpd.cdprev(),
×
39
        Some(Commands::Stop) => mpd.stop(),
×
40

41
        Some(Commands::Clear) => mpd.clear(),
×
42
        Some(Commands::Outputs) => mpd.outputs(),
×
43
        Some(Commands::Queued) => mpd.queued(),
×
44
        Some(Commands::Shuffle) => mpd.shuffle(),
×
45
        Some(Commands::Lsplaylists) => mpd.lsplaylists(),
×
46
        Some(Commands::Playlist { name }) => mpd.playlist(name),
×
47
        Some(Commands::Repeat { state }) => mpd.repeat(state),
×
48
        Some(Commands::Random { state }) => mpd.random(state),
×
49
        Some(Commands::Single { state }) => mpd.single(state),
×
50
        Some(Commands::Consume { state }) => mpd.consume(state),
×
51
        Some(Commands::Crossfade { seconds }) => mpd.crossfade(seconds),
×
52

53
        Some(Commands::Save { name }) => mpd.save(&name),
×
54
        Some(Commands::Rm { name }) => mpd.rm(&name),
×
55
        Some(Commands::Volume { volume }) => mpd.set_volume(&volume),
×
56
        Some(Commands::Stats) => mpd.stats(),
×
57
        Some(Commands::Version) => mpd.version(),
×
58

59
        Some(Commands::Status) | None => mpd.current_status(),
×
60
    };
61

62
    match result {
×
63
        Ok(Some(output)) => println!("{output}"),
×
64
        Ok(None) => (),
×
65
        Err(e) => handle_error(e),
×
66
    }
67
}
68

69
fn handle_error(error: impl std::fmt::Display) -> ! {
×
70
    let err_text = error.to_string();
×
71
    if !err_text.is_empty() {
×
72
        println!("{err_text}");
×
73
    }
74
    std::process::exit(1);
×
75
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc