finalize
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -155,7 +155,7 @@ checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||
|
||||
[[package]]
|
||||
name = "pallet"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"colored",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "pallet"
|
||||
version = "0.1.0"
|
||||
version = "1.0.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
30
src/app.rs
30
src/app.rs
@@ -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(())
|
||||
}
|
||||
|
||||
1
src/templates/gitignoretemplate
Normal file
1
src/templates/gitignoretemplate
Normal file
@@ -0,0 +1 @@
|
||||
target/
|
||||
Reference in New Issue
Block a user