use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(name = "issuerd")]
#[command(about = "Issuerd Identity and Access Management Server")]
#[command(version)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
#[arg(short, long, global = true, action = clap::ArgAction::Count)]
pub verbose: u8,
#[arg(short, long, global = true, action = clap::ArgAction::Count)]
pub quiet: u8,
}
impl Cli {
pub fn verbosity(&self) -> i32 {
self.verbose as i32 - self.quiet as i32
}
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Daemon {
#[arg(short, long, default_value = "issuerd.toml")]
config: PathBuf,
},
Provision {
#[arg(short, long, default_value = "issuerd.toml")]
config: PathBuf,
#[arg(short, long)]
file: PathBuf,
},
Openapi {
#[arg(short, long, default_value = "openapi.json")]
output: PathBuf,
},
Example {
#[arg(value_enum)]
kind: ExampleKind,
#[arg(short, long, default_value = "examples/issuerd.example.toml")]
output: PathBuf,
},
Healthcheck {
#[arg(long, default_value = "http://localhost:8080/ready")]
url: String,
#[arg(long)]
insecure: bool,
#[arg(long, default_value = "5")]
timeout_secs: u64,
},
}
#[derive(Clone, Debug, ValueEnum)]
pub enum ExampleKind {
ServerConfig,
ProvisionConfig,
}