From e52ad0bc24ad4915482e809297c26a69c1668c7b Mon Sep 17 00:00:00 2001 From: godsfryingpan Date: Mon, 23 Mar 2026 09:55:03 -0600 Subject: [PATCH] add --force-recompile flag (#4) issue: #2 Reviewed-on: http://192.168.1.227:3000/sfrembling/pallet/pulls/4 Co-authored-by: godsfryingpan Co-committed-by: godsfryingpan --- src/app.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/app.rs b/src/app.rs index 65de1a0..95ca391 100644 --- a/src/app.rs +++ b/src/app.rs @@ -29,6 +29,9 @@ enum Subcommand { Init, /// Run the local project Run { + /// Force recompilation of the project + #[arg(long, short)] + force_recompile: bool, /// The build mode to use mode: Option, /// Arguments to pass to the project binary @@ -37,6 +40,9 @@ enum Subcommand { }, /// Build the local project Build { + /// Force recompilation of the project + #[arg(long, short)] + force_recompile: bool, /// The build mode to use mode: Option, }, @@ -86,8 +92,12 @@ impl App { } _ => {} }, - Subcommand::Run { mode, args } => { - match build(&mode) { + Subcommand::Run { + mode, + args, + force_recompile, + } => { + match build(&mode, force_recompile) { Err(e) => { eprintln!("Error building project: {e}"); std::process::exit(1); @@ -99,7 +109,10 @@ impl App { std::process::exit(1); } } - Subcommand::Build { mode } => match build(&mode) { + Subcommand::Build { + mode, + force_recompile, + } => match build(&mode, force_recompile) { Err(e) => { eprintln!("Error building project: {e}"); std::process::exit(1); @@ -220,7 +233,7 @@ fn get_config() -> Option { toml::from_str(&raw).ok() } -fn build(mode: &Option) -> std::io::Result<()> { +fn build(mode: &Option, force_recompile: bool) -> std::io::Result<()> { let conf = match get_config() { Some(conf) => conf, None => { @@ -249,7 +262,7 @@ fn build(mode: &Option) -> std::io::Result<()> { let old_compute_path = PathBuf::from(format!("target/{}/.build_hash", build_config.name)); - if old_compute_path.exists() { + if old_compute_path.exists() && !force_recompile { let text = std::fs::read_to_string(old_compute_path)?; if hash.trim() == text.trim() {