This commit is contained in:
2026-03-22 18:22:27 -05:00
parent e7b8596205
commit 84a6196416
4 changed files with 33 additions and 2 deletions

2
Cargo.lock generated
View File

@@ -155,7 +155,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
[[package]]
name = "pallet"
version = "0.1.0"
version = "1.0.0"
dependencies = [
"clap",
"colored",

View File

@@ -1,6 +1,6 @@
[package]
name = "pallet"
version = "0.1.0"
version = "1.0.0"
edition = "2024"
[dependencies]

View File

@@ -8,8 +8,10 @@ use colored::Colorize;
use glob::glob;
const MAIN_C: &str = include_str!("templates/main.c");
const GITIGNORE: &str = include_str!("templates/gitignoretemplate");
#[derive(clap::Parser)]
#[clap(version)]
pub struct App {
#[clap(subcommand)]
command: Subcommand,
@@ -36,6 +38,8 @@ enum Subcommand {
/// The build mode to use
mode: Option<String>,
},
/// Clean all in progress files
Clean,
}
impl App {
@@ -75,6 +79,13 @@ impl App {
}
_ => {}
},
Subcommand::Clean => match clean() {
Err(e) => {
eprintln!("Error cleaning project: {e}");
std::process::exit(1);
}
_ => {}
},
}
}
}
@@ -110,6 +121,7 @@ fn create_project<P: AsRef<Path>>(directory: P) -> std::io::Result<()> {
std::fs::create_dir("src")?;
std::fs::write("src/main.c", MAIN_C)?;
std::fs::write(".gitignore", GITIGNORE)?;
let config = crate::config::Config::new(&pathdir.to_string_lossy());
@@ -225,3 +237,21 @@ fn run(mode: &Option<String>, args: Option<Vec<String>>) -> std::io::Result<()>
Ok(())
}
fn clean() -> std::io::Result<()> {
if let None = get_config() {
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"no Pallet.toml found in local dir",
));
}
std::fs::remove_dir_all("target/")?;
println!(
" {} removed files in target/ directory",
"Successfully".green().bold()
);
Ok(())
}

View File

@@ -0,0 +1 @@
target/