pegase 0.2.0

Cli to generate secret config files from yaml recipe
Documentation
#![allow(clippy::print_stderr)]
#![allow(clippy::print_stdout)]

use std::{
    path::Path,
    process::{ExitCode, Termination},
};

use clap::Parser;
use pegase::recipe::Recipe;

enum ReturnCode {
    Ok = 0,
    InvalidConfiguration = 1,
    GenerationError = 2,
}

impl Termination for ReturnCode {
    fn report(self) -> ExitCode {
        ExitCode::from(self as u8)
    }
}

#[derive(Parser, Debug)]
#[command(version, about)]
struct Args {
    recipe: String,
}

fn main() -> ReturnCode {
    let args = Args::parse();

    let recipe = match Recipe::from_file(Path::new(&args.recipe)) {
        Ok(recipe) => recipe,
        Err(err) => {
            eprintln!("{err}");

            return ReturnCode::InvalidConfiguration;
        }
    };

    if let Err(err) = recipe.generate_files() {
        eprintln!("{err}");

        return ReturnCode::GenerationError;
    }

    ReturnCode::Ok
}