use std::path::PathBuf;
use clap::{Parser, Subcommand};
use url::Url;
use crate::rules::MergePolicy;
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
#[command(name = "onevcs", version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
pub enum Command {
Register(RegisterArgs),
Repos(ReposArgs),
Resolve(ResolveArgs),
Session {
#[command(subcommand)]
command: SessionCommand,
},
Publish(PublishArgs),
Recover(RecoverArgs),
Recoverable(RecoverableArgs),
Integrate(IntegrateArgs),
Sync(SyncArgs),
Events(EventsArgs),
Artifact {
#[command(subcommand)]
command: ArtifactCommand,
},
Rules {
#[command(subcommand)]
command: RulesCommand,
},
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct RegisterArgs {
pub path: PathBuf,
#[arg(long, value_name = "URL")]
pub origin: Option<Url>,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct ReposArgs {
#[arg(long)]
pub audit_gates: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct ResolveArgs {
pub repo: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
pub enum SessionCommand {
Open(SessionOpenArgs),
Adopt(SessionTokenArgs),
Close(SessionTokenArgs),
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct SessionOpenArgs {
pub repo: String,
#[arg(long, value_name = "B")]
pub branch: Option<String>,
#[arg(long, value_name = "B")]
pub base: Option<String>,
#[arg(long, value_name = "ALIAS")]
pub execution_checkout: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct SessionTokenArgs {
pub token: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct PublishArgs {
pub token: String,
#[arg(long, value_name = "P")]
pub policy: Option<MergePolicy>,
#[arg(long, value_name = "T")]
pub title: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct RecoverArgs {
pub branch: String,
#[arg(long, value_name = "PATH")]
pub repo: PathBuf,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct RecoverableArgs {
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct IntegrateArgs {
#[arg(required = true, num_args = 1..)]
pub branches: Vec<String>,
#[arg(long)]
pub push: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct SyncArgs {
pub branch: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct EventsArgs {
pub token: String,
#[arg(long)]
pub follow: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
pub enum ArtifactCommand {
Cat(ArtifactCatArgs),
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct ArtifactCatArgs {
pub id: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
pub enum RulesCommand {
Check(RulesCheckArgs),
}
#[derive(Debug, Clone, PartialEq, Eq, Parser)]
pub struct RulesCheckArgs {
pub repo: String,
}