1use std::{env, time::Duration};
2
3use toast_logger_win::{Notification, ToastLogger};
4
5pub fn main() -> anyhow::Result<()> {
6 let args: Vec<String> = env::args().skip(1).collect();
7 let duration = if args.is_empty() {
8 Duration::ZERO
9 } else {
10 Duration::from_secs(args[0].parse()?)
11 };
12
13 let mut builder = ToastLogger::builder();
14 let message = if duration.is_zero() {
15 "This message shouldn't expire".into()
16 } else {
17 let message = format!("This message should expire in {duration:?}.");
18 builder.create_notification(move |records| {
19 let mut notification = Notification::new_with_records(records)?;
20 notification.expires_in(duration)?;
21 Ok(notification)
22 });
23 message
24 };
25 builder.max_level(log::LevelFilter::Info).init()?;
26
27 log::info!("{}", message);
28 Ok(())
29}