ref:main
pub mod agent;
pub mod auth;
pub mod board;
pub mod branch;
pub mod ci;
pub mod commit;
pub mod deploy;
pub mod epic;
pub mod issue;
pub mod label;
pub mod milestone;
pub mod pr;
pub mod release;
pub mod repo;
pub mod requirement;
pub mod runner;
pub mod ssh_key;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(
name = "anvil",
about = "CLI for Anvil — a self-hosted code forge",
version = include_str!(concat!(env!("OUT_DIR"), "/version.txt"))
)]
pub struct Cli {
/// Output JSON instead of human-readable tables/details. Applies to
/// list and view subcommands. Useful for scripting.
#[arg(long, global = true)]
pub json: bool,
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand)]
pub enum Command {
/// Authenticate with an Anvil server
Auth(auth::AuthArgs),
/// Repository operations
Repo(repo::RepoArgs),
/// Pull request operations
Pr(pr::PrArgs),
/// Issue operations
Issue(issue::IssueArgs),
/// Epic operations (epics group related issues)
Epic(epic::EpicArgs),
/// CI pipeline operations
Ci(ci::CiArgs),
/// Commit operations
Commit(commit::CommitArgs),
/// Branch operations
Branch(branch::BranchArgs),
/// Release operations
Release(release::ReleaseArgs),
/// Manage requirements and traceability
Requirement(requirement::RequirementArgs),
/// Deployment operations
Deploy(deploy::DeployArgs),
/// AI agent operations
Agent(agent::AgentArgs),
/// CI runner management
Runner(runner::RunnerArgs),
/// Label operations
Label(label::LabelArgs),
/// SSH key management
#[command(name = "ssh-key")]
SshKey(ssh_key::SshKeyArgs),
/// Board operations
Board(board::BoardArgs),
/// Milestone operations
Milestone(milestone::MilestoneArgs),
}
pub async fn run(cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
crate::output::set_json_mode(cli.json);
match cli.command {
Command::Auth(args) => auth::run(args).await,
Command::Repo(args) => repo::run(args).await,
Command::Pr(args) => pr::run(args).await,
Command::Issue(args) => issue::run(args).await,
Command::Epic(args) => epic::run(args).await,
Command::Ci(args) => ci::run(args).await,
Command::Commit(args) => commit::run(args).await,
Command::Branch(args) => branch::run(args).await,
Command::Release(args) => release::run(args).await,
Command::Requirement(args) => requirement::run(args).await,
Command::Deploy(args) => deploy::run(args).await,
Command::Agent(args) => agent::run(args).await,
Command::Runner(args) => runner::run(args)
.await
.map_err(|e| -> Box<dyn std::error::Error> { e }),
Command::Label(args) => label::run(args).await,
Command::SshKey(args) => ssh_key::run(args).await,
Command::Board(args) => board::run(args).await,
Command::Milestone(args) => milestone::run(args).await,
}
}