Add repeat current attrubute

This commit is contained in:
Anas Elgarhy 2023-02-12 05:22:43 +02:00
parent 29a5336858
commit a74efe45bb
No known key found for this signature in database
GPG key ID: 0501802A1D496528

View file

@ -5,6 +5,7 @@ use crate::cmus::CmusError;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct PlayerSettings { pub struct PlayerSettings {
pub repeat: bool, pub repeat: bool,
pub repeat_current: bool,
pub shuffle: Shuffle, pub shuffle: Shuffle,
pub aaa_mode: AAAMode, pub aaa_mode: AAAMode,
pub volume: Volume, pub volume: Volume,
@ -63,6 +64,7 @@ impl FromStr for PlayerSettings {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut repeat = false; let mut repeat = false;
let mut repeat_current = false;
let mut shuffle = Shuffle::default(); let mut shuffle = Shuffle::default();
let mut aaa_mode = AAAMode::default(); let mut aaa_mode = AAAMode::default();
let mut volume = Volume::default(); let mut volume = Volume::default();
@ -74,6 +76,7 @@ impl FromStr for PlayerSettings {
match key { match key {
"repeat" => repeat = value == "true", "repeat" => repeat = value == "true",
"repeat_current" => repeat_current = value == "true",
"shuffle" => shuffle = Shuffle::from_str(value)?, "shuffle" => shuffle = Shuffle::from_str(value)?,
"aaa_mode" => aaa_mode = AAAMode::from_str(value)?, "aaa_mode" => aaa_mode = AAAMode::from_str(value)?,
"vol_left" => volume.left = value.parse().map_err(|e: ParseIntError| CmusError::UnknownError(e.to_string()))?, "vol_left" => volume.left = value.parse().map_err(|e: ParseIntError| CmusError::UnknownError(e.to_string()))?,
@ -85,6 +88,7 @@ impl FromStr for PlayerSettings {
Ok(Self { Ok(Self {
repeat, repeat,
repeat_current,
shuffle, shuffle,
aaa_mode, aaa_mode,
volume, volume,
@ -131,6 +135,7 @@ mod tests {
assert_eq!(settings, Ok(PlayerSettings { assert_eq!(settings, Ok(PlayerSettings {
repeat: false, repeat: false,
repeat_current: false,
shuffle: Shuffle::Tracks, shuffle: Shuffle::Tracks,
aaa_mode: AAAMode::Artist, aaa_mode: AAAMode::Artist,
volume: Volume { volume: Volume {