use std::path::PathBuf;
use clap::{Args, Parser, Subcommand};
use crate::channel::SurfaceKind;
pub const DEFAULT_ROUND_BUDGET_SECONDS: u64 = 14_400;
pub const DEFAULT_HEARTBEAT_INTERVAL_SECONDS: u64 = 1_800;
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
#[command(name = "onepipeline", version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
#[command(rename_all = "kebab-case")]
pub enum Command {
Start(StartArgs),
Adopt(RunArgs),
#[command(subcommand)]
Round(RoundCommand),
#[command(subcommand)]
Channel(ChannelCommand),
Next(RunArgs),
Reply(ReplyArgs),
Surface(SurfaceArgs),
Attest(AttestArgs),
Stop(StopArgs),
Runs(RunsArgs),
Status(OptionalRunArgs),
Host,
Monitor(RunArgs),
Results(RunArgs),
Goals(OptionalRunArgs),
Transcript(TranscriptArgs),
Telemetry(TelemetryArgs),
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct StartArgs {
pub plan: PathBuf,
#[arg(long, conflicts_with = "detach")]
pub attach: bool,
#[arg(long)]
pub detach: bool,
#[arg(long, value_name = "SECONDS", default_value_t = DEFAULT_ROUND_BUDGET_SECONDS)]
pub round_budget: u64,
#[arg(long, value_name = "SECONDS", default_value_t = DEFAULT_HEARTBEAT_INTERVAL_SECONDS)]
pub heartbeat_interval: u64,
#[arg(long = "set", value_name = "PATH=VALUE")]
pub dag_sets: Vec<String>,
#[arg(long = "node-set", value_name = "PATH=VALUE")]
pub node_sets: Vec<String>,
#[arg(long)]
pub acknowledge_concurrent: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
#[command(rename_all = "kebab-case")]
pub enum RoundCommand {
Run(RunArgs),
Next(RunArgs),
}
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
#[command(rename_all = "kebab-case")]
pub enum ChannelCommand {
Serve(RunArgs),
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct RunArgs {
pub run: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct OptionalRunArgs {
pub run: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct ReplyArgs {
pub run: String,
pub file: Option<PathBuf>,
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct SurfaceArgs {
pub run: String,
#[arg(long, value_enum)]
pub kind: SurfaceKind,
#[arg(long, value_name = "TEXT")]
pub message: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct AttestArgs {
pub run: String,
pub reference: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct StopArgs {
pub run: String,
#[arg(long)]
pub force: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct RunsArgs {
#[arg(long)]
pub mine: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct TranscriptArgs {
pub run: String,
pub node: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Args)]
pub struct TelemetryArgs {
pub run: Option<String>,
#[arg(long)]
pub breakdown: bool,
}