Skip to main content

gen_circleci_orb/
lib.rs

1//! # gen-circleci-orb
2//!
3//! Generate a CircleCI orb from a CLI program definition.
4
5use anyhow::Result;
6use clap::Parser;
7
8pub mod ci_patcher;
9pub mod commands;
10pub mod help_parser;
11pub mod orb_generator;
12pub mod output_writer;
13
14/// Command-line interface for gen-circleci-orb.
15#[derive(Debug, Parser)]
16#[command(author, version, about, long_about = None)]
17pub struct Cli {
18    #[command(subcommand)]
19    pub command: Commands,
20}
21
22/// Available subcommands.
23#[derive(Debug, clap::Subcommand)]
24pub enum Commands {
25    /// Generate orb source files from a CLI binary's --help output.
26    Generate(commands::generate::Generate),
27    /// Wire orb generation into an existing repo's CI configuration.
28    Init(commands::init::Init),
29}
30
31impl Cli {
32    /// Execute the selected command.
33    pub fn run(&self) -> Result<()> {
34        match &self.command {
35            Commands::Generate(cmd) => cmd.run(),
36            Commands::Init(cmd) => cmd.run(),
37        }
38    }
39}