Allow for both startup options to be None

This commit is contained in:
Luc Perkins 2024-05-17 13:32:43 -03:00
parent cfe5cb78c5
commit c0b7181ddc
No known key found for this signature in database
GPG key ID: 16DB1108FB591835

View file

@ -133,12 +133,6 @@ impl Args {
)));
}
if self.startup_notification_url.is_none() && self.startup_notification_file.is_none() {
return Err(error::Error::Config(String::from(
"you must specify either --startup-notification-url or --startup-notification-file",
)));
}
Ok(())
}
}
@ -405,12 +399,14 @@ async fn main_cli() -> Result<()> {
}
}
// Notify of startup via file
// Notify of startup by writing "1" to the specified file
if let Some(startup_notification_file_path) = args.startup_notification_file {
let file_contents: &[u8] = b"1";
tracing::debug!("Startup notification via file at {startup_notification_file_path:?}");
let mut notification_file = File::create(&startup_notification_file_path).await?;
notification_file.write_all(b"1").await?;
notification_file.write_all(file_contents).await?;
tracing::debug!("Created startup notification file at {startup_notification_file_path:?}");
}