use clap::{Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(name = "halldyll")]
#[command(author, version, about, long_about = None)]
#[command(propagate_version = true)]
pub struct Cli {
#[arg(short, long, global = true, env = "HALLDYLL_CONFIG")]
pub config: Option<PathBuf>,
#[arg(short, long, global = true)]
pub verbose: bool,
#[arg(long, global = true, default_value = "text")]
pub output: OutputFormat,
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Init {
#[arg(default_value = ".")]
path: PathBuf,
#[arg(short, long)]
force: bool,
},
Validate {
#[arg(short, long)]
warnings: bool,
},
Plan {
#[arg(short, long)]
detailed: bool,
},
Apply {
#[arg(short, long)]
yes: bool,
#[arg(long)]
continue_on_error: bool,
},
Status {
#[arg(short, long)]
detailed: bool,
#[arg(long)]
health: bool,
},
Reconcile {
#[arg(short, long)]
yes: bool,
#[arg(long, default_value = "3")]
max_attempts: u32,
},
Destroy {
#[arg(short, long)]
yes: bool,
#[arg(long)]
keep_volumes: bool,
},
Logs {
pod: Option<String>,
#[arg(short, long)]
follow: bool,
#[arg(short, long, default_value = "100")]
tail: u32,
},
Drift,
State {
#[command(subcommand)]
command: StateCommands,
},
}
#[derive(Subcommand, Debug)]
pub enum StateCommands {
Show,
Lock {
#[arg(long)]
holder: Option<String>,
},
Unlock {
#[arg(long)]
lock_id: Option<String>,
#[arg(long)]
force: bool,
},
Pull,
Push {
#[arg(long)]
force: bool,
},
}
#[derive(Debug, Clone, Copy, Default, clap::ValueEnum)]
pub enum OutputFormat {
#[default]
Text,
Json,
}
impl Cli {
#[must_use]
pub fn parse_args() -> Self {
Self::parse()
}
}