use clap::builder::styling::AnsiColor::{BrightBlue, White, Yellow};
use clap::builder::Styles;
use clap::Parser;
use invar::Loader;
use semver::Version;
const STYLES: Styles = Styles::styled()
.usage(Yellow.on_default().bold())
.literal(BrightBlue.on_default().bold())
.placeholder(White.on_default().bold())
.header(Yellow.on_default().bold());
#[derive(Parser, Debug)]
#[command(version, author, about, styles(STYLES))]
pub struct Options {
#[command(subcommand)]
pub subcommand: Subcommand,
#[arg(short('f'), long("format"), default_value_t = OutputFormat::default())]
pub output_format: OutputFormat,
}
#[derive(clap::Subcommand, Debug)]
pub enum Subcommand {
Pack {
#[command(subcommand)]
action: PackAction,
},
Component {
#[command(subcommand)]
action: ComponentAction,
},
Server {
#[command(subcommand)]
action: ServerAction,
},
}
#[derive(clap::Subcommand, Debug)]
pub enum PackAction {
#[clap(visible_alias("new"), visible_alias("create"))]
Setup {
#[arg(short, long)]
name: Option<String>,
#[arg(long)]
minecraft_version: Option<Version>,
#[arg(short, long)]
loader: Option<Loader>,
#[arg(long)]
loader_version: Option<Version>,
#[arg(short, long)]
overwrite: bool,
},
Show,
Export,
}
#[derive(clap::Subcommand, Debug)]
pub enum ComponentAction {
List,
#[command(arg_required_else_help = true)]
Add {
ids: Vec<String>,
#[arg(short('d'), long("debug"))]
show_metadata: bool,
},
Update {
slugs: Vec<String>,
},
#[clap(visible_alias("delete"))]
#[command(arg_required_else_help = true)]
Remove {
slugs: Vec<String>,
},
}
#[derive(clap::Subcommand, Debug)]
pub enum ServerAction {
Setup,
Start,
Stop,
Status,
Backup {
#[command(subcommand)]
action: BackupAction,
},
}
#[derive(clap::Subcommand, Debug)]
pub enum BackupAction {
List,
Create,
Gc,
}
#[derive(Debug, Default, Clone, PartialEq, Eq, clap::ValueEnum, strum::Display)]
#[strum(serialize_all = "kebab-case")]
pub enum OutputFormat {
#[default]
Human,
Yaml,
}