From 35c47a529db5f8117a199be67fc51e94908ad35b Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Wed, 4 Nov 2020 11:31:09 +0200 Subject: [PATCH] Send a notification at the end of the run (fix #554) --- src/main.rs | 10 +++++++++- src/terminal.rs | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 80af7383..ebcf555a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -381,7 +381,15 @@ fn run() -> Result<()> { } } - if post_command_failed || runner.report().data().iter().any(|(_, result)| result.failed()) { + let failed = post_command_failed || runner.report().data().iter().any(|(_, result)| result.failed()); + terminal::notify_desktop( + format!( + "Topgrade finished {}", + if failed { "with errors" } else { "sucessfully" } + ), + None, + ); + if failed { Err(StepFailed.into()) } else { Ok(()) diff --git a/src/terminal.rs b/src/terminal.rs index 7326946d..faca2ace 100644 --- a/src/terminal.rs +++ b/src/terminal.rs @@ -296,3 +296,7 @@ pub fn set_desktop_notifications(desktop_notifications: bool) { pub fn prompt_yesno(question: &str) -> Result { TERMINAL.lock().unwrap().prompt_yesno(question) } + +pub fn notify_desktop>(message: P, timeout: Option) { + TERMINAL.lock().unwrap().notify_desktop(message, timeout) +}