orcs 0.0.8

Microservices monorepo orchestration tool
Documentation
use crate::{Error, Project, Recipe, Service};
use clap::ArgMatches;
use tracing::{info, instrument};

#[instrument(skip(subcommand))]
pub fn new(project_path: &str, subcommand: &ArgMatches) -> Result<(), Error> {
    info!("Create new resource");
    // Retrieve the project
    let project = Project::from_path(project_path)?;

    // Retrieve information
    let rtype = subcommand.value_of("type").expect("missing type");
    let name = subcommand.value_of("name").expect("missing name");
    let template = subcommand.value_of("template");

    match rtype {
        "service" => Service::create(project, name, template),
        // Templates not yet supported for recipes
        "recipe" => Recipe::create(project, name),
        _ => Err(Error::CreateError(
            "incorrect resource type",
            rtype.to_string(),
        )),
    }
}