mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 17:20:14 +00:00
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:
parent
482c923507
commit
4f7e9c22a1
9 changed files with 187 additions and 56 deletions
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue