diff --git a/README.md b/README.md index 9c29abf..21014bd 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ Install directly from source $ cd completion-notifier $ ./install.sh - $ completion-notifier -v $ completion-notifier -h ``` @@ -28,6 +27,18 @@ It is easy as passing the command directly, by default a notification will be se ```shell $ completion-notifier ping google.com ``` +### Profiles +Profiles can used to group notification clients by a specific name. + +```toml +[profiles.default] +sendto = ["desktop","email.default"] + +[profiles.work] +sendto = ["desktop","gchat.work","email.work"] + +``` + ### Triggers Triggers can be added to send custom notifications based on the requirement. for example, diff --git a/src/enums.rs b/src/enums.rs index 13492c0..64c8f10 100644 --- a/src/enums.rs +++ b/src/enums.rs @@ -1,4 +1,3 @@ -use strum::IntoEnumIterator; use strum_macros::{Display, EnumIter, FromRepr}; #[derive(Default, Debug, Clone, Copy, Display, FromRepr, EnumIter)] diff --git a/src/helpers.rs b/src/helpers.rs index 2ada1ea..8b7fea4 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -1,5 +1,5 @@ use tokio::fs::File; -use tokio::io::{self, AsyncReadExt, AsyncWriteExt}; +use tokio::io::{AsyncReadExt, AsyncWriteExt}; use super::Config; diff --git a/src/main.rs b/src/main.rs index 1dd0fd3..e0e83c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,14 +2,13 @@ use std::collections::HashMap; use clap::Parser; use serde::Deserialize; -use tokio::io::{self, AsyncBufReadExt, BufReader}; +use tokio::io::{AsyncBufReadExt, BufReader}; use tokio::process::Command; mod constants; mod enums; mod helpers; mod notification; -mod send_emails; #[derive(Parser, Debug)] #[command(version, about, long_about = None,arg_required_else_help = true,trailing_var_arg=true)] @@ -62,8 +61,6 @@ struct EmailConfig { async fn main() -> anyhow::Result<()> { let mut args = Args::parse(); - println!("{:?}", args.triggers); - let config = helpers::app_state().await?; // helpers::handle_ctrlc().await; @@ -88,24 +85,26 @@ async fn main() -> anyhow::Result<()> { // following line will handle it println!("{}", line); - // Check if the line contains a trigger string - let contains_a_trigger = args - .triggers - .as_ref() - .unwrap() - .split(",") - .collect::>() - .iter() - .any(|t| line.contains(t)); - if contains_a_trigger { - let _ = notification::Notification::new( - &config, - &args.profiles.as_ref().unwrap(), - "Trigger Detected".to_string(), - "".to_string(), - ) - .send() - .await; + if args.triggers.is_some() { + // Check if the line contains a trigger string + let contains_a_trigger = args + .triggers + .as_ref() + .unwrap() + .split(",") + .collect::>() + .iter() + .any(|t| line.contains(t)); + if contains_a_trigger { + let _ = notification::Notification::new( + &config, + &args.profiles.as_ref().unwrap(), + "Trigger Detected".to_string(), + "".to_string(), + ) + .send() + .await; + } } } diff --git a/src/notification.rs b/src/notification.rs index eee461d..d57f54a 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -1,4 +1,3 @@ -use super::enums::ConfigType; use futures::stream::{self, StreamExt}; use lettre::transport::smtp::authentication::Credentials; use lettre::{Message, SmtpTransport, Transport}; @@ -25,8 +24,6 @@ impl<'b> Notification<'b> { } } - pub async fn read_local_config() {} - pub async fn send_desktop(&self) -> anyhow::Result<()> { let _ = notify_rust::Notification::new() .summary(&self.title) @@ -37,7 +34,7 @@ impl<'b> Notification<'b> { } pub async fn send_gchat(&self, gchat_config: &super::GChatConfig) -> anyhow::Result<()> { - let result = reqwest::Client::new() + let _ = reqwest::Client::new() .post(gchat_config.webhook.to_string()) .header("Content-Type", "application/json; charset=UTF-8") .json(&serde_json::json!({ diff --git a/src/send_emails.rs b/src/send_emails.rs deleted file mode 100644 index 8b13789..0000000 --- a/src/send_emails.rs +++ /dev/null @@ -1 +0,0 @@ -