use clap::{Args, Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Parser)]
#[command(
version,
about = "Control in-repo YAML work queues",
arg_required_else_help = true
)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand)]
pub enum Command {
Init(InitArgs),
Status(LedgerArgs),
Check(CheckArgs),
Add(AddArgs),
Start(IdArgs),
Archive(ArchiveArgs),
Show(IdArgs),
Fmt(FmtArgs),
Schema(SchemaArgs),
Instructions,
}
#[derive(Args)]
pub struct FmtArgs {
#[command(flatten)]
pub ledger: LedgerArgs,
#[arg(long)]
pub check: bool,
}
#[derive(Args)]
pub struct SchemaArgs {
#[arg(short = 'o', long, value_hint = clap::ValueHint::FilePath)]
pub out: Option<PathBuf>,
}
#[derive(Args, Clone)]
pub struct CheckArgs {
#[command(flatten)]
pub ledger: LedgerArgs,
#[arg(long)]
pub no_git: bool,
}
#[derive(Args, Clone)]
pub struct LedgerArgs {
#[arg(short = 'f', long, value_hint = clap::ValueHint::FilePath)]
pub file: Option<PathBuf>,
}
#[derive(Args)]
pub struct InitArgs {
#[arg(short = 'p', long)]
pub prefix: String,
#[command(flatten)]
pub ledger: LedgerArgs,
#[arg(long)]
pub force: bool,
}
#[derive(Args)]
pub struct AddArgs {
#[command(flatten)]
pub ledger: LedgerArgs,
#[arg(short = 't', long)]
pub title: String,
#[arg(short = 's', long)]
pub scope: String,
#[arg(short = 'o', long)]
pub outcome: String,
#[arg(short = 'a', long = "acceptance", required = true)]
pub acceptance: Vec<String>,
#[arg(long)]
pub patch: Option<String>,
}
#[derive(Args)]
pub struct IdArgs {
pub id: String,
#[command(flatten)]
pub ledger: LedgerArgs,
}
#[derive(Args)]
pub struct ArchiveArgs {
pub id: String,
#[command(flatten)]
pub ledger: LedgerArgs,
#[arg(short = 'e', long = "evidence", required = true)]
pub evidence: Vec<String>,
#[arg(long, value_enum, default_value = "completed")]
pub disposition: Disposition,
}
#[derive(Clone, Copy, ValueEnum)]
pub enum Disposition {
Completed,
Dropped,
}
impl Disposition {
#[must_use]
pub fn as_str(self) -> &'static str {
match self {
Self::Completed => "completed",
Self::Dropped => "dropped",
}
}
}