feat(commands): implement Display traits for Token and Command to have some basic 'doc gen', split Toggle into Enable and Disable

This commit is contained in:
dusk 2025-01-08 18:31:59 +09:00
parent 482c923507
commit 4f7e9c22a1
No known key found for this signature in database
9 changed files with 187 additions and 56 deletions

View file

@ -18,6 +18,8 @@ pub mod server_config;
pub mod switch;
pub mod system;
use std::fmt::Display;
use smol_str::SmolStr;
use crate::{
@ -47,6 +49,18 @@ impl Command {
}
}
impl Display for Command {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for (idx, token) in self.tokens.iter().enumerate() {
write!(f, "{}", token)?;
if idx < self.tokens.len() - 1 {
write!(f, " ")?;
}
}
write!(f, " - {}", self.help)
}
}
#[macro_export]
macro_rules! command {
([$($v:expr),+], $cb:expr, $help:expr) => {