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

johnallen3d / mpc-rs / #34

17 Sep 2023 01:49PM UTC coverage: 0.0%. Remained the same
#34

push

web-flow
feat: add the `repeat` command (#20)

Relates to #16

15 of 15 new or added lines in 3 files covered. (100.0%)

0 of 146 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/args.rs
1
use clap::{Parser, Subcommand, ValueEnum};
2
use serde::Serialize;
3

4
/// Music Player Daemon client written in Rust
5
#[derive(Debug, Parser)]
6
pub(crate) struct Cli {
7
    #[command(subcommand)]
8
    pub(crate) command: Option<Commands>,
9
    /// Set output format
10
    #[clap(long, value_enum, default_value_t=OutputFormat::Json)]
11
    pub(crate) format: OutputFormat,
12
    /// Set the ip address the mpd server is listening on
13
    #[clap(long, default_value = "127.0.0.1")]
14
    pub(crate) bind_to_address: Option<String>,
15
    /// Set the port the mpd server is listening on
16
    #[clap(long, default_value = "6600")]
17
    pub(crate) port: Option<String>,
18
}
19

20
#[derive(Debug, Subcommand)]
21
pub(crate) enum Commands {
22
    //
23
    // playback related commands
24
    //
25
    /// Print the current song
26
    #[command()]
27
    Current,
28
    /// Start the player
29
    #[command()]
30
    Play,
31
    /// Next song in the queue
32
    #[command()]
33
    Next,
34
    /// Previous song in the queue
35
    #[command()]
36
    Prev,
37
    /// Pause the player
38
    #[command()]
39
    Pause,
40
    /// Pause the player if it is playing
41
    #[command()]
42
    PauseIfPlaying,
43
    /// CD player like previous song
44
    #[command()]
45
    Cdprev,
46
    /// Toggle play/pause
47
    #[command()]
48
    Toggle,
49
    /// Stop the player
50
    #[command()]
51
    Stop,
52

53
    //
54
    // playlist related commands
55
    //
56
    /// Clear the current playlist
57
    #[command()]
58
    Clear,
59
    /// Display the next song in the queue
60
    #[command()]
61
    Queued,
62
    /// Shuffle the queue
63
    #[command()]
64
    Shuffle,
65
    /// Toggle repeat or set to provide state
66
    #[command()]
67
    Repeat { state: Option<OnOff> },
68

69
    /// Set the volume to specified value <num> or increase/decrease it [+-]<num>
70
    #[command()]
71
    Volume { volume: String },
72

73
    //
74
    // output related commands
75
    //
76
    /// Get the current status of the player
77
    #[command()]
78
    Status,
79
}
80

81
#[derive(Clone, Debug, ValueEnum)]
82
pub enum OutputFormat {
83
    Text,
84
    Json,
85
}
86

87
#[derive(Clone, Debug, PartialEq, Serialize, ValueEnum)]
88
pub enum OnOff {
89
    On,
90
    Off,
91
}
92

93
impl From<bool> for OnOff {
94
    fn from(value: bool) -> Self {
×
95
        if value {
×
96
            OnOff::On
×
97
        } else {
98
            OnOff::Off
×
99
        }
100
    }
101
}
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