auric 0.1.6

CLI for the Ember-inspired Auric SPA framework
use crate::make::run_make;
use clap::Parser;
use std::path::PathBuf;

pub(crate) mod adapter;
pub(crate) mod component;
pub(crate) mod model;
pub(crate) mod route;
pub(crate) mod template;

#[derive(Debug, Parser)]
pub struct Opts {
    #[command(subcommand)]
    pub subcommand: Subcommand,
}

#[derive(Debug, Parser)]
pub enum Subcommand {
    #[command(name = "adapter")]
    Adapter(adapter::Opts),

    #[command(name = "component")]
    Component(component::Opts),

    #[command(name = "model")]
    Model(model::Opts),

    #[command(name = "route")]
    Route(route::Opts),

    #[command(name = "template")]
    Template(template::Opts),
}

pub async fn run(subcommand: Subcommand) -> anyhow::Result<()> {
    match subcommand {
        Subcommand::Adapter(adapter::Opts { name }) => adapter::run(name).await,
        Subcommand::Component(component::Opts { name }) => component::run(name).await,
        Subcommand::Model(model::Opts { name }) => model::run(name).await,
        Subcommand::Route(route::Opts { name }) => route::run(name).await,
        Subcommand::Template(template::Opts { name }) => template::run(name).await,
    }?;
    run_make(&PathBuf::from("."))?;
    Ok(())
}