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

johnallen3d / mpc-rs / #48

17 Sep 2023 04:23PM UTC coverage: 0.0%. Remained the same
#48

push

johnallen3d
feat: update status output

- include fields to match `mpc`
- update `text` format
- make `status` default command (redux)

Resolves #26

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

0 of 213 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 std::fmt;
2

3
use clap::{Parser, Subcommand, ValueEnum};
4
use serde::Serialize;
5

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

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

55
    //
56
    // playlist related commands
57
    //
58
    /// Clear the current playlist
59
    #[command()]
60
    Clear,
61
    /// Display the next song in the queue
62
    #[command()]
63
    Queued,
64
    /// Shuffle the queue
65
    #[command()]
66
    Shuffle,
67
    /// Toggle repeat mode or set to provided state
68
    #[command()]
69
    Repeat { state: Option<OnOff> },
70
    /// Toggle random mode or set to provided state
71
    #[command()]
72
    Random { state: Option<OnOff> },
73
    /// Toggle single mode or set to provided state
74
    #[command()]
75
    Single { state: Option<OnOff> },
76
    /// Toggle consume mode or set to provided state
77
    #[command()]
78
    Consume { state: Option<OnOff> },
79

80
    /// Set the volume to specified value <num> or increase/decrease it [+-]<num>
81
    #[command()]
82
    Volume { volume: String },
83

84
    /// Provide the mpd version and the mp-cli version
85
    #[command()]
86
    Version,
87

88
    //
89
    // output related commands
90
    //
91
    /// Get the current status of the player
92
    #[command()]
93
    Status,
94
}
95

96
#[derive(Clone, Debug, ValueEnum)]
97
pub enum OutputFormat {
98
    Text,
99
    Json,
100
}
101

102
#[derive(Clone, Debug, PartialEq, Serialize, ValueEnum)]
103
pub enum OnOff {
104
    On,
105
    Off,
106
}
107

108
impl From<bool> for OnOff {
109
    fn from(value: bool) -> Self {
×
110
        if value {
×
111
            OnOff::On
×
112
        } else {
113
            OnOff::Off
×
114
        }
115
    }
116
}
117

118
impl fmt::Display for OnOff {
119
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
×
120
        match self {
×
121
            OnOff::On => write!(f, "on"),
×
122
            OnOff::Off => write!(f, "off"),
×
123
        }
124
    }
125
}
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