//! Server CLI interface

#[derive(clap::Parser)]
#[command(version, about, long_about = None)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Command,

    /// Path to configuration file.
    #[arg(long, default_value_t = default_config_location())]
    pub config: camino::Utf8PathBuf,
}

#[derive(clap::Subcommand, Default)]
pub enum Command {
    #[default]
    Serve,
}

fn default_config_location() -> camino::Utf8PathBuf {
    let xdg_dirs = xdg::BaseDirectories::with_prefix("ascend").unwrap();
    let config_path = xdg_dirs.get_config_file("config.toml");
    camino::Utf8PathBuf::from_path_buf(config_path).unwrap()
}

#[cfg(test)]
#[test]
fn verify_cli() {
    <Cli as clap::CommandFactory>::command().debug_assert()
}
