use std::error::Error;
use clap::{Arg, ArgMatches, Command};
use dxm_init::vcs::VcsOption;
pub fn cli() -> Command {
Command::new("init")
.about("Create a new server in the current directory")
.arg(
Arg::new("vcs")
.help("The version control system to use (git, none)")
.long("vcs")
.default_value("git")
.value_parser(clap::value_parser!(VcsOption)),
)
}
pub fn execute(args: &ArgMatches) -> Result<(), Box<dyn Error>> {
let vcs = args.get_one::<VcsOption>("vcs").expect("no vcs");
let path = std::env::current_dir()?;
log::info!("creating files");
dxm_init::server(&path, vcs)?;
let (path, mut manifest) = crate::util::manifest::find(path)?;
crate::util::artifacts::update(path, &mut manifest)?;
Ok(())
}