use std::fmt::Display;

use serde::{Deserialize, Serialize};

#[derive(Debug, Serialize, Deserialize, Clone, Copy)]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
pub enum LoopMode {
    /// Disables looping
    None,

    /// When the end of the tracklist is reached, loop back to the beginning
    Loop,

    /// When the end of the tracklist is reached, reshuffle the tracklist using the shuffle mode and loop
    LoopAndReshuffle,

    /// When the end of the current track is reached, repeat
    RepeatTrack,
}

impl Display for LoopMode {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            LoopMode::None => f.write_str("None"),
            LoopMode::Loop => f.write_str("Loop"),
            LoopMode::LoopAndReshuffle => f.write_str("Loop And Reshuffle"),
            LoopMode::RepeatTrack => f.write_str("Repeat Track"),
        }
    }
}
