Desktop notifications in macOS #285
This commit is contained in:
committed by
GitHub
parent
27e98a3815
commit
b049151993
@@ -1,6 +1,8 @@
|
||||
use chrono::{Local, Timelike};
|
||||
use console::{style, Term};
|
||||
use lazy_static::lazy_static;
|
||||
#[cfg(target_os = "macos")]
|
||||
use notify_rust::Notification;
|
||||
use std::cmp::{max, min};
|
||||
use std::env;
|
||||
use std::io::{self, Write};
|
||||
@@ -124,7 +126,8 @@ impl Terminal {
|
||||
.ok();
|
||||
}
|
||||
|
||||
fn should_retry(&mut self, interrupted: bool) -> Result<bool, io::Error> {
|
||||
#[allow(unused_variables)]
|
||||
fn should_retry(&mut self, interrupted: bool, step_name: &str) -> Result<bool, io::Error> {
|
||||
if self.width.is_none() {
|
||||
return Ok(false);
|
||||
}
|
||||
@@ -132,6 +135,16 @@ impl Terminal {
|
||||
if self.set_title {
|
||||
self.term.set_title("Topgrade - Awaiting user");
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
Notification::new()
|
||||
.summary("Topgrade")
|
||||
.body(&format!("{} failed", step_name))
|
||||
.appname("topgrade")
|
||||
.timeout(0)
|
||||
.show()
|
||||
.ok();
|
||||
|
||||
self.term
|
||||
.write_fmt(format_args!(
|
||||
"\n{}",
|
||||
@@ -178,8 +191,8 @@ impl Default for Terminal {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn should_retry(interrupted: bool) -> Result<bool, io::Error> {
|
||||
TERMINAL.lock().unwrap().should_retry(interrupted)
|
||||
pub fn should_retry(interrupted: bool, step_name: &str) -> Result<bool, io::Error> {
|
||||
TERMINAL.lock().unwrap().should_retry(interrupted, step_name)
|
||||
}
|
||||
|
||||
pub fn print_separator<P: AsRef<str>>(message: P) {
|
||||
|
||||
Reference in New Issue
Block a user