From 1ab6ecba6f509b7b76865d65c77ecebc51efd2d3 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Sun, 21 Apr 2024 16:04:38 +0100 Subject: Initial commit --- src/actions/terminal_print.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/actions/terminal_print.rs (limited to 'src/actions/terminal_print.rs') diff --git a/src/actions/terminal_print.rs b/src/actions/terminal_print.rs new file mode 100644 index 0000000..02536c7 --- /dev/null +++ b/src/actions/terminal_print.rs @@ -0,0 +1,28 @@ +use super::Action; +use crate::message::MessageConfig; +use crate::message::MessageParams; +use anyhow::Result; +use async_trait::async_trait; + +#[derive(Debug)] +pub struct TerminalPrintAction<'a> { + message_config: &'a MessageConfig, +} + +impl<'a> TerminalPrintAction<'a> { + pub fn new(message_config: &'a MessageConfig) -> Self { + Self { message_config } + } +} + +#[async_trait] +impl Action<'_> for TerminalPrintAction<'_> { + async fn run(&self, params: Option<&MessageParams<'_, '_>>) -> Result<()> { + println!( + "{}\n{}\n", + self.message_config.subject(params)?, + self.message_config.body(params)? + ); + Ok(()) + } +} -- cgit v1.2.3-70-g09d2