mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-12 08:40:11 +00:00
refactor(commands): separate commands definitions and other code into modules
This commit is contained in:
parent
405ac11d74
commit
af523a4c23
24 changed files with 293 additions and 216 deletions
57
crates/commands/src/commands.rs
Normal file
57
crates/commands/src/commands.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
pub mod admin;
|
||||
pub mod api;
|
||||
pub mod autoproxy;
|
||||
pub mod checks;
|
||||
pub mod commands;
|
||||
pub mod config;
|
||||
pub mod dashboard;
|
||||
pub mod debug;
|
||||
pub mod fun;
|
||||
pub mod group;
|
||||
pub mod help;
|
||||
pub mod import_export;
|
||||
pub mod member;
|
||||
pub mod message;
|
||||
pub mod misc;
|
||||
pub mod random;
|
||||
pub mod server_config;
|
||||
pub mod switch;
|
||||
pub mod system;
|
||||
|
||||
use crate::{command, token::Token};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Command {
|
||||
// TODO: fix hygiene
|
||||
pub tokens: Vec<Token>,
|
||||
pub help: String,
|
||||
pub cb: String,
|
||||
}
|
||||
|
||||
impl Command {
|
||||
pub fn new(
|
||||
tokens: impl IntoIterator<Item = Token>,
|
||||
help: impl ToString,
|
||||
cb: impl ToString,
|
||||
) -> Self {
|
||||
Self {
|
||||
tokens: tokens.into_iter().collect(),
|
||||
help: help.to_string(),
|
||||
cb: cb.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! command {
|
||||
([$($v:expr),+], $cb:expr, $help:expr) => {
|
||||
$crate::commands::Command::new([$($v.clone()),*], $help, $cb)
|
||||
};
|
||||
}
|
||||
|
||||
pub fn all() -> Vec<Command> {
|
||||
(help::cmds())
|
||||
.chain(system::cmds())
|
||||
.chain(member::cmds())
|
||||
.collect()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue