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 {
#[arg(value_name = "MEDIA")]
pub media: Option<String>,
#[arg(short, long)]
pub windowed: bool,
#[arg(short, long, value_name = "VOLUME")]
pub volume: Option<f64>,
#[arg(short, long)]
pub muted: bool,
#[arg(short, long, value_name = "SPEED", default_value = "1.0")]
pub speed: f64,
#[arg(long, value_name = "PATH")]
pub ffplay_path: Option<PathBuf>,
#[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(())
}
}