use clap::{Parser, Subcommand, ValueHint};
use std::path::PathBuf;
#[derive(Subcommand, Debug)]
pub(crate) enum Commands {
Check(FontCommand),
Update(FontCommand),
CheckLib(CheckLibCommand),
}
#[derive(Parser, Debug)]
pub(crate) struct FontCommand {
#[arg(default_value = "./font_config.toml")]
pub(crate) config: PathBuf,
#[arg(short, long, num_args = 1.., value_name = "DIR")]
pub(crate) library: Option<Vec<PathBuf>>,
#[arg(short, long, default_value = "false")]
pub(crate) github: bool,
}
#[derive(Parser, Debug)]
pub(crate) struct CheckLibCommand {
#[arg(short, long, num_args = 1.., value_name = "DIR")]
pub(crate) library: Option<Vec<PathBuf>>,
#[arg(short, long, default_value = "false")]
pub(crate) github: bool,
#[arg(short, long, value_name = "OUTPUT", num_args = 0..=1, value_hint = ValueHint::FilePath)]
pub(crate) output: Option<Option<PathBuf>>,
}
impl FontCommand {
pub(crate) fn validate(&self) -> Result<(), String> {
if self.github && self.library.is_none() {
return Err(
"When '--github' is set to true, '--library' must also be provided.".to_string(),
);
}
Ok(())
}
}