use crate::doctor;
use crate::error::CliError;
use crate::scaffold::{self, GitInit, NewOptions};
pub fn new(name: &str) -> Result<(), CliError> {
doctor::require(doctor::NEW_PREREQUISITES, "frame new")?;
doctor::warn_if_chrome_missing();
let target_parent =
std::env::current_dir().map_err(|source| CliError::CurrentDir { source })?;
let path = scaffold::generate(&NewOptions {
name: name.to_owned(),
target_parent,
})?;
println!("created {}", path.display());
match scaffold::init_repo(&path)? {
GitInit::Initialized => println!("initialized a git repository with an initial commit"),
GitInit::SkippedInsideExistingRepo => {
println!("inside an existing git repository; left version control untouched");
}
GitInit::SkippedGitMissing => {
println!("git is not installed; created the application without version control");
}
}
println!();
println!(" cd {name}");
println!(" frame run # build it and serve it");
println!(" frame test # prove it end to end, real browser included");
Ok(())
}