2025-10-11 14:35:29 -07:00
|
|
|
use crate::context::SproutContext;
|
|
|
|
|
use anyhow::Result;
|
2025-10-11 14:11:31 -07:00
|
|
|
use serde::{Deserialize, Serialize};
|
2025-10-05 00:09:53 -07:00
|
|
|
use std::rc::Rc;
|
|
|
|
|
|
2025-10-19 21:44:05 -07:00
|
|
|
/// The configuration of the print action.
|
2025-10-11 14:11:31 -07:00
|
|
|
#[derive(Serialize, Deserialize, Default, Clone)]
|
|
|
|
|
pub struct PrintConfiguration {
|
2025-10-19 21:44:05 -07:00
|
|
|
/// The text to print to the console.
|
2025-10-11 14:11:31 -07:00
|
|
|
#[serde(default)]
|
|
|
|
|
pub text: String,
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-19 21:44:05 -07:00
|
|
|
/// Executes the print action with the specified `configuration` inside the provided `context`.
|
2025-10-11 14:35:29 -07:00
|
|
|
pub fn print(context: Rc<SproutContext>, configuration: &PrintConfiguration) -> Result<()> {
|
2025-10-05 00:09:53 -07:00
|
|
|
println!("{}", context.stamp(&configuration.text));
|
2025-10-11 14:35:29 -07:00
|
|
|
Ok(())
|
2025-10-05 00:09:53 -07:00
|
|
|
}
|