bloomery 1.6.4

A lightweight, minimalist build system for Java written in Rust.
use anyhow::Result;
use clap::Parser;

#[macro_use]
mod macros;

mod cli;
mod commands;
mod config;
mod templates;

use cli::{Cli, Commands};

fn main() -> Result<()> {
    let cli = Cli::parse();

    match cli.command {
        Commands::Init { name, template } => {
            let template_name = match template {
                Some(t) => t,
                None => {
                    let global = config::load_global_config()?;
                    global.default_template
                }
            };
            commands::init::init(name, &template_name)?;
        }
        Commands::Install { name, path } => templates::external::install_template(name, &path)?,
        Commands::Build => commands::build::build()?,
        Commands::BuildFile { path } => commands::build_file::build_file(&path)?,
        Commands::Run => {
            commands::build::build()?;
            commands::run::run()?;
        }
        Commands::RunFile { path } => {
            commands::run_file::run_file(&path)?;
        }
        Commands::Clean => commands::clean::clean()?,
    }

    Ok(())
}