simpleci 0.1.1

A simple tool to run CICD pipelines locally
mod pipeline;
use clap::{Parser, Subcommand};

#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Cli {
    #[command(subcommand)]
    command: Option<Commands>,
}

#[derive(Subcommand)]
enum Commands {
    /// Pipeline execution
    Exec {
        /// Execute a pipeline
        #[arg(short, long, default_value_t = String::from(".simple-ci.yml"))]
        file: String,
    },
    /// Create the git hook on commit
    Start,
    /// Delete the git hook
    Stop,
    /// Create the git hook and a default .simple-ci.yml file
    Init,
    /// Delete artifacts from previous pipelines
    Clean,
    /// Manage configuration
    Config {
        /// Config subcommand: set, get, or show
        subcommand: Option<String>,
        /// Configuration key
        key: Option<String>,
        /// Configuration value (for set command)
        value: Option<String>,
    },
}

fn main() {
    let cli = Cli::parse();

    match &cli.command {
        Some(Commands::Exec { file }) => pipeline::main_exec(file),
        Some(Commands::Start) => pipeline::main_start(),
        Some(Commands::Stop) => pipeline::main_stop(),
        Some(Commands::Init) => pipeline::main_init(),
        Some(Commands::Clean) => pipeline::main_clean(),
        Some(Commands::Config {
            subcommand,
            key,
            value,
        }) => pipeline::main_config(subcommand.as_deref(), key.as_deref(), value.as_deref()),
        None => {
            eprintln!("Error: no arguments given. Try simpleci --help")
        }
    }
}