diff --git a/Cargo.lock b/Cargo.lock index d91d01ae..dcde0ca0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1834,7 +1834,7 @@ dependencies = [ [[package]] name = "topgrade" -version = "9.0.1" +version = "9.1.0" dependencies = [ "anyhow", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 1c63663a..2a00c1ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ categories = ["os"] keywords = ["upgrade", "update"] license-file = "LICENSE" repository = "https://github.com/r-darwish/topgrade" -version = "9.0.1" +version = "9.1.0" authors = ["Roey Darwish Dror "] exclude = ["doc/screenshot.gif"] edition = "2018" diff --git a/config.example.toml b/config.example.toml index 5cc7eaea..df506e86 100644 --- a/config.example.toml +++ b/config.example.toml @@ -37,6 +37,9 @@ # Cleanup temporary or old files #cleanup = true +# Skip sending a notification at the end of a run +#skip_notify = true + [git] #max_concurrency = 5 # Additional git repositories to pull diff --git a/src/config.rs b/src/config.rs index fcfdcdee..001c242a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -272,6 +272,7 @@ pub struct ConfigFile { cleanup: Option, notify_each_step: Option, accept_all_windows_updates: Option, + skip_notify: Option, bashit_branch: Option, only: Option>, composer: Option, @@ -428,6 +429,10 @@ pub struct CommandLineArgs { #[clap(short = 'k', long = "keep")] keep_at_end: bool, + /// Skip sending a notification at the end of a run + #[clap(long = "skip-notify")] + skip_notify: bool, + /// Say yes to package manager's prompt #[clap(short = 'y', long = "yes", arg_enum, multiple_values = true, min_values = 0)] yes: Option>, @@ -613,6 +618,15 @@ impl Config { self.opt.keep_at_end || env::var("TOPGRADE_KEEP_END").is_ok() } + /// Skip sending a notification at the end of a run + pub fn skip_notify(&self) -> bool { + if let Some(yes) = self.config_file.skip_notify { + return yes; + } + + self.opt.skip_notify + } + /// Whether to set the terminal title pub fn set_title(&self) -> bool { self.config_file.set_title.unwrap_or(true) diff --git a/src/main.rs b/src/main.rs index 1757cdaa..ea591742 100644 --- a/src/main.rs +++ b/src/main.rs @@ -466,13 +466,17 @@ fn run() -> Result<()> { } let failed = post_command_failed || runner.report().data().iter().any(|(_, result)| result.failed()); - terminal::notify_desktop( - format!( - "Topgrade finished {}", - if failed { "with errors" } else { "successfully" } - ), - None, - ); + + if !config.skip_notify() { + terminal::notify_desktop( + format!( + "Topgrade finished {}", + if failed { "with errors" } else { "successfully" } + ), + None, + ); + } + if failed { Err(StepFailed.into()) } else {