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() {