make say use Option

This commit is contained in:
Raptorox 2026-07-28 17:34:33 +02:00
parent f01661339e
commit 32304f4ea0
No known key found for this signature in database
GPG key ID: 8B3556FC3ED1F6D8

View file

@ -1,16 +1,16 @@
#[derive(Default)]
pub struct SayCommand {
message: String
message: Option<String>
}
impl SayCommand {
pub fn message(mut self, msg: impl Into<String>) -> Self {
self.message = msg.into();
self.message = Some(msg.into());
self
}
pub fn build(self) -> super::Command {
let message = self.message;
let message = self.message.unwrap_or("Hello, world!".to_string());
let s = format!("say {message}");
super::Command(s)
}