bular 0.0.2

CLI for managing Bular deployments
use std::path::{absolute, PathBuf};

use crate::config::default_config;

#[derive(clap::Args)]
#[command(about = "Create a new Bular project in an existing directory")]
pub struct Command {}

impl Command {
    pub async fn run(&self, cwd: PathBuf) {
        // TODO: Prompt the user to setup with Bular
        let bular_id = None;

        let cwd = absolute(cwd).unwrap();
        let path = cwd.join("bular.yaml");
        if path.exists() {
            eprintln!("Already found a bular configuration. Please delete it and try again!");
            std::process::exit(1);
        }

        println!("{:?}", path);

        // TODO: Use Cargo metadata to get the name of the crate or ask the user if multiple
        let name = cwd.file_name().unwrap().to_str().unwrap().to_string();

        std::fs::write(
            path,
            serde_yaml::to_string(&default_config(name, bular_id)).unwrap(),
        )
        .unwrap();

        // TODO: Pretty UI
        println!("Done!");
    }
}