summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index ab23ab7..dad98c6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,7 +3,6 @@ use clap::Parser;
3use cli::Subcommands; 3use cli::Subcommands;
4use config::Config; 4use config::Config;
5use error::{Error, Result}; 5use error::{Error, Result};
6use notify_rust::Urgency;
7use tracing::{debug, error, level_filters::LevelFilter}; 6use tracing::{debug, error, level_filters::LevelFilter};
8use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; 7use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
9 8
@@ -72,6 +71,21 @@ fn run_cli() -> Result<()> {
72 Ok(()) 71 Ok(())
73} 72}
74 73
74enum Urgency {
75 Normal,
76 Critical
77}
78
79#[cfg(feature = "notifications")]
80impl From<Urgency> for notify_rust::Urgency {
81 fn from(value: Urgency) -> Self {
82 match value {
83 Urgency::Normal => Self::Normal,
84 Urgency::Critical => Self::Critical,
85 }
86 }
87}
88
75fn send_notification(summary: &str, body: &str, urgency: Urgency) -> Result<()> { 89fn send_notification(summary: &str, body: &str, urgency: Urgency) -> Result<()> {
76 #[cfg(feature = "notifications")] 90 #[cfg(feature = "notifications")]
77 { 91 {
@@ -86,7 +100,7 @@ fn send_notification(summary: &str, body: &str, urgency: Urgency) -> Result<()>
86 .body(body) 100 .body(body)
87 .icon(&icon.to_string_lossy()) 101 .icon(&icon.to_string_lossy())
88 .timeout(0) 102 .timeout(0)
89 .urgency(urgency) 103 .urgency(urgency.into())
90 .show()?; 104 .show()?;
91 } 105 }
92 Ok(()) 106 Ok(())