From e7b859620555ab79fadccc75175f3a62ca335e13 Mon Sep 17 00:00:00 2001 From: Shea Frembling Date: Sun, 22 Mar 2026 18:17:51 -0500 Subject: [PATCH] more dev work --- Cargo.lock | 10 ++++++++++ Cargo.toml | 1 + src/app.rs | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 822128f..2c6cfd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -98,6 +98,15 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" +[[package]] +name = "colored" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" +dependencies = [ + "windows-sys", +] + [[package]] name = "equivalent" version = "1.0.2" @@ -149,6 +158,7 @@ name = "pallet" version = "0.1.0" dependencies = [ "clap", + "colored", "glob", "serde", "toml", diff --git a/Cargo.toml b/Cargo.toml index 7751c89..c6f8d05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ edition = "2024" [dependencies] clap = { version = "4.6.0", features = ["derive"] } +colored = "3.1.1" glob = "0.3.3" serde = { version = "1.0.228", features = ["derive"] } toml = "1.0.7" diff --git a/src/app.rs b/src/app.rs index 73fed55..de44063 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4,6 +4,7 @@ use std::{ process::Command, }; +use colored::Colorize; use glob::glob; const MAIN_C: &str = include_str!("templates/main.c"); @@ -41,28 +42,26 @@ impl App { pub fn run(self) { match self.command { Subcommand::New { name } => match create_project(&name) { - Ok(_) => println!("Successfully created new project '{name}'."), Err(e) => { eprintln!("Error creating project '{name}': {e}"); std::process::exit(1); } + _ => {} }, Subcommand::Init => match create_project(".") { - Ok(_) => println!("Successfully initialized new project."), Err(e) => { eprintln!("Error initializing project: {e}"); std::process::exit(1); } + _ => {} }, Subcommand::Run { mode, args } => { match build(&mode) { - Ok(_) => { - println!("Successfully built project."); - } Err(e) => { eprintln!("Error building project: {e}"); std::process::exit(1); } + _ => {} }; if let Err(e) = run(&mode, args) { eprintln!("Error running project: {e}"); @@ -70,19 +69,29 @@ impl App { } } Subcommand::Build { mode } => match build(&mode) { - Ok(_) => { - println!("Successfully built project."); - } Err(e) => { eprintln!("Error building project: {e}"); std::process::exit(1); } + _ => {} }, } } } fn create_project>(directory: P) -> std::io::Result<()> { + let name = if directory.as_ref().to_string_lossy() == "." { + String::new() + } else { + format!(" '{}'", directory.as_ref().to_string_lossy()) + }; + + println!( + " {} binary (application){}", + "Creating".green().bold(), + name + ); + let pathdir = directory.as_ref(); if pathdir.exists() && pathdir.to_string_lossy() != "." { @@ -135,6 +144,15 @@ fn build(mode: &Option) -> std::io::Result<()> { "build layout not found", ))?; + println!( + " {} '{}' profile for project '{}'", + "Building".green().bold(), + build_config.name, + conf.name + ); + + let start = std::time::Instant::now(); + std::fs::create_dir_all(format!("target/{}", build_config.name))?; let mut command = Command::new("gcc"); @@ -159,6 +177,16 @@ fn build(mode: &Option) -> std::io::Result<()> { child.wait()?; + let stop = start.elapsed(); + + println!( + " {} '{}' profile for project '{}' in {:.2}s", + "Finished".green().bold(), + build_config.name, + conf.name, + stop.as_secs_f64() + ); + Ok(()) } @@ -176,6 +204,13 @@ fn run(mode: &Option, args: Option>) -> std::io::Result<()> "build layout not found", ))?; + println!( + " {} '{}' profile for project '{}'", + "Running".green().bold(), + build_config.name, + conf.name + ); + let mut command = Command::new(format!("target/{}/{}", build_config.name, conf.name)); if let Some(args) = args {