feat: matcha new scaffolds from embedded starter

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-11 12:59:38 -05:00
1 parent caabb51ae0
commit 06849ebab4
3 files changed
+50 -1

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
use std::io::{Error, ErrorKind};
use std::path::Path;
use crate::template;
pub fn run(name: &str, template_url: Option<&str>) -> std::io::Result<()> {
let dest = Path::new(name);
if dest.exists() {
return Err(Error::new(ErrorKind::AlreadyExists,
format!("'{name}' already exists")));
}
std::fs::create_dir_all(dest)?;
match template_url {
None => template::write_starter(dest, name)?,
Some(_) => return Err(Error::new(ErrorKind::Unsupported,
"--template-url not implemented yet")),
}
println!("✓ created {name}\n cd {name} && matcha run");
Ok(())
}
+7 -1
View File
@@ -1,4 +1,5 @@
mod cli;
mod cmd_new;
mod runtime;
mod template;
@@ -8,7 +9,12 @@ use cli::{Cli, Command};
fn main() {
let cli = Cli::parse();
match cli.command {
Command::New { .. } => eprintln!("new: not yet implemented"),
Command::New { name, template_url } => {
if let Err(e) = cmd_new::run(&name, template_url.as_deref()) {
eprintln!("error: {e}");
std::process::exit(1);
}
}
Command::Run => eprintln!("run: not yet implemented"),
Command::Create { .. } => eprintln!("create: not yet implemented"),
Command::Add { .. } => eprintln!("add: not yet implemented"),