From d9f9183d5d2e37a7186a7629ea0770b5dbd97c1b Mon Sep 17 00:00:00 2001 From: n3tw0rth Date: Mon, 27 Jan 2025 20:20:25 +0530 Subject: [PATCH 1/4] chore(docs): small change" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 21014bd..ef5d892 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Install directly from source it is better to use a alias for the binary, ```bash #.bashrc -alias notif='completion-notifier' +alias notify='completion-notifier' ``` ## Usage From a727125e999453fdd8d7b3de8e518f2a23cb7441 Mon Sep 17 00:00:00 2001 From: n3tw0rth Date: Mon, 27 Jan 2025 20:38:49 +0530 Subject: [PATCH 2/4] fix(config): update the application name for config file --- src/helpers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers.rs b/src/helpers.rs index ebd580e..b75ae94 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -4,7 +4,7 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt}; use super::Config; pub async fn app_state() -> anyhow::Result { - let config_path = dirs::config_dir().unwrap().join("fetched"); + let config_path = dirs::config_dir().unwrap().join("completion-notifier"); let filename = "config.toml"; let path = config_path.join(filename); From 2bbcd7cca8445235626932ad106736af8314c0a7 Mon Sep 17 00:00:00 2001 From: n3tw0rth Date: Sat, 1 Feb 2025 17:00:39 +0530 Subject: [PATCH 3/4] refactor(flags): removed verbose flag --- src/main.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index e0e83c7..ae3ab42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,9 +28,6 @@ struct Args { #[arg(short, long)] triggers: Option, - - #[arg(long, action)] - verbose: bool, } #[derive(Deserialize, Debug)] From 768fe8398d8c21553eae6b76a1cfcb216a51d114 Mon Sep 17 00:00:00 2001 From: n3tw0rth Date: Wed, 12 Feb 2025 17:30:34 +0530 Subject: [PATCH 4/4] feat(triggers): add trigger name to the trigger notification --- src/main.rs | 22 +++++++++++----------- src/notification.rs | 7 +++++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index ae3ab42..7b092f9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,12 +56,11 @@ struct EmailConfig { #[tokio::main] async fn main() -> anyhow::Result<()> { + // Parse the command line arguments let mut args = Args::parse(); let config = helpers::app_state().await?; - // helpers::handle_ctrlc().await; - let program = args.run.get(0).cloned().unwrap(); let program_args = args.run.split_off(1); @@ -84,23 +83,24 @@ async fn main() -> anyhow::Result<()> { if args.triggers.is_some() { // Check if the line contains a trigger string - let contains_a_trigger = args + let contained_triggers: Vec<_> = args .triggers .as_ref() .unwrap() .split(",") - .collect::>() - .iter() - .any(|t| line.contains(t)); - if contains_a_trigger { - let _ = notification::Notification::new( + .filter(|trigger| line.contains(trigger)) + .collect(); + + if contained_triggers.len() > 0 { + notification::Notification::new( &config, &args.profiles.as_ref().unwrap(), "Trigger Detected".to_string(), - "".to_string(), + contained_triggers.join(","), ) - .send() - .await; + .send_trigger() + .await + .unwrap(); } } } diff --git a/src/notification.rs b/src/notification.rs index d57f54a..d397b98 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -115,4 +115,11 @@ impl<'b> Notification<'b> { Ok(()) } + + pub async fn send_trigger(&mut self) -> anyhow::Result<()> { + // expect a list of triggers found and will update the notification massage based on that + self.msg = format!("Triggers invoked {}", self.msg); + self.send().await?; + Ok(()) + } }