add say
This commit is contained in:
parent
809d24a70d
commit
db4f7f9369
3 changed files with 38 additions and 1 deletions
17
src/command/mod.rs
Normal file
17
src/command/mod.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
pub struct Command(String);
|
||||||
|
|
||||||
|
mod say;
|
||||||
|
|
||||||
|
impl Command {
|
||||||
|
pub fn raw(cmd: &str) -> Self {
|
||||||
|
Self(cmd.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn say() -> say::SayCommand {
|
||||||
|
say::SayCommand::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/command/say.rs
Normal file
17
src/command/say.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct SayCommand {
|
||||||
|
message: String
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SayCommand {
|
||||||
|
pub fn message(mut self, msg: impl Into<String>) -> Self {
|
||||||
|
self.message = msg.into();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build(self) -> super::Command {
|
||||||
|
let message= self.message;
|
||||||
|
let s = format!("say {message}");
|
||||||
|
super::Command(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,2 +1,5 @@
|
||||||
mod client;
|
mod client;
|
||||||
pub use client::{RconClient, RconError, RconResult};
|
pub use client::{RconClient, RconError, RconResult};
|
||||||
|
|
||||||
|
mod command;
|
||||||
|
pub use command::Command;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue