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 {
#[arg(long, global = true)]
pub json: bool,
#[command(subcommand)]
pub command: Command,
}
#[derive(Subcommand)]
pub enum Command {
Auth(auth::AuthArgs),
Repo(repo::RepoArgs),
Pr(pr::PrArgs),
Issue(issue::IssueArgs),
Epic(epic::EpicArgs),
Ci(ci::CiArgs),
Commit(commit::CommitArgs),
Branch(branch::BranchArgs),
Release(release::ReleaseArgs),
Requirement(requirement::RequirementArgs),
Deploy(deploy::DeployArgs),
Agent(agent::AgentArgs),
Runner(runner::RunnerArgs),
Label(label::LabelArgs),
#[command(name = "ssh-key")]
SshKey(ssh_key::SshKeyArgs),
Board(board::BoardArgs),
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,
}
}