use clap::{Args, Subcommand};
use std::path::PathBuf;
#[derive(Debug, Args)]
pub struct InitCmd {
#[arg(default_value = ".")]
pub path: PathBuf,
#[arg(short, long)]
pub force: bool,
#[arg(short, long, default_value = "default")]
pub template: String,
}
#[derive(Debug, Args)]
pub struct ValidateCmd {
pub path: PathBuf,
#[arg(long)]
pub strict: bool,
}
#[derive(Debug, Args)]
pub struct VersionCmd {}
pub fn add_common_subcommands(cmd: clap::Command) -> clap::Command {
cmd.subcommand(
clap::Command::new("init")
.about("Initialize a new project")
.arg(
clap::arg!([path] "Path to initialize")
.default_value(".")
.value_parser(clap::value_parser!(PathBuf)),
)
.arg(clap::arg!(-f --force "Force overwrite"))
.arg(clap::arg!(-t --template <TEMPLATE> "Template to use").default_value("default")),
)
.subcommand(
clap::Command::new("validate")
.about("Validate a config or project")
.arg(clap::arg!([path] "Path to validate").value_parser(clap::value_parser!(PathBuf)))
.arg(clap::arg!(--strict "Strict mode: warnings are errors")),
)
.subcommand(clap::Command::new("version").about("Print version + build info"))
}
pub trait CommonSubcommand {}
impl CommonSubcommand for InitCmd {}
impl CommonSubcommand for ValidateCmd {}
impl CommonSubcommand for VersionCmd {}
#[derive(Debug, Subcommand)]
pub enum CommonCommands {
Init(InitCmd),
Validate(ValidateCmd),
Version(VersionCmd),
}