diff --git a/src/main.rs b/src/main.rs index fab67cd..99749ef 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,9 @@ struct Opt { #[structopt(short, long)] verbose: bool, + + #[structopt(long)] + force_cycle: bool, } fn get_files(files: &[String]) -> Option> { @@ -32,7 +35,7 @@ fn get_files(files: &[String]) -> Option> { Some(all_files) } -fn do_update(compose_project: compose::ComposeProject) { +fn do_update(compose_project: compose::ComposeProject, force_cycle: bool) { info!("Processing {}...", compose_project); let pre_images = compose_project.get_images(); if pre_images.is_empty() { @@ -44,14 +47,14 @@ fn do_update(compose_project: compose::ComposeProject) { let post_images = compose_project.get_images(); - if post_images == pre_images { - info!("No change to images"); - } else { + if force_cycle || post_images != pre_images { info!("Changes detected - Cycling container"); warn!("Stopping container"); compose_project.down(); warn!("Starting container"); compose_project.up(); + } else { + info!("No change to images"); } } @@ -86,6 +89,6 @@ fn main() { info!("Found {} projects", compose_projects.len()); for compose_project in compose_projects { - do_update(compose_project); + do_update(compose_project, opts.force_cycle); } }