bckplayer 0.1.0

A cross-platform CLI media player interface for VLC
Documentation
use clap::Parser;
use std::path::PathBuf;

#[derive(Parser, Debug)]
#[command(
    name = "bckplayer", 
    about = "A cross-platform CLI media player interface for VLC",
    version = "0.1.0"
)]
pub struct Args {
    /// Media source to play (file path or URL)
    #[arg(value_name = "MEDIA")]
    pub media: Option<String>,

    /// Start in windowed mode instead of fullscreen
    #[arg(short, long)]
    pub windowed: bool,

    /// Set initial volume (0-100)
    #[arg(short, long, value_name = "VOLUME")]
    pub volume: Option<f64>,

    /// Start muted
    #[arg(short, long)]
    pub muted: bool,

    /// Set playback speed
    #[arg(short, long, value_name = "SPEED", default_value = "1.0")]
    pub speed: f64,

    /// VLC library path (auto-detected if not specified)
    #[arg(long, value_name = "PATH")]
    pub ffplay_path: Option<PathBuf>,

    /// Enable debug logging
    #[arg(short, long)]
    pub debug: bool,
}

impl Args {
    pub fn parse() -> Self {
        <Self as Parser>::parse()
    }

    pub fn validate(&self) -> Result<(), String> {
        if let Some(volume) = self.volume {
            if !(0.0..=100.0).contains(&volume) {
                return Err("Volume must be between 0 and 100".to_string());
            }
        }

        if self.speed <= 0.0 || self.speed > 10.0 {
            return Err("Speed must be between 0.1 and 10.0".to_string());
        }

        Ok(())
    }
}