refactor: separate commands into command_parser, command_definitions crates

This commit is contained in:
dusk 2025-01-21 04:31:03 +09:00
parent 4f390e2a14
commit 0c012e98b5
No known key found for this signature in database
33 changed files with 464 additions and 378 deletions

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,29 @@
use super::*;
pub fn cmds() -> impl Iterator<Item = Command> {
let cfg = ["config", "cfg"];
let autoproxy = ["autoproxy", "ap"];
[
command!([cfg, autoproxy, ["account", "ac"]], "cfg_ap_account_show")
.help("Shows autoproxy status for the account"),
command!(
[cfg, autoproxy, ["account", "ac"], Toggle],
"cfg_ap_account_update"
)
.help("Toggles autoproxy for the account"),
command!([cfg, autoproxy, ["timeout", "tm"]], "cfg_ap_timeout_show")
.help("Shows the autoproxy timeout"),
command!(
[
cfg,
autoproxy,
["timeout", "tm"],
any!(Disable, Reset, ("timeout", OpaqueString::SINGLE)) // todo: we should parse duration / time values
],
"cfg_ap_timeout_update"
)
.help("Sets the autoproxy timeout"),
]
.into_iter()
}

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,9 @@
use super::*;
pub fn cmds() -> impl Iterator<Item = Command> {
[
command!(["thunder"], "fun_thunder"),
command!(["meow"], "fun_meow"),
]
.into_iter()
}

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,11 @@
use super::*;
pub fn cmds() -> impl Iterator<Item = Command> {
let help = ["help", "h"];
[
command!([help], "help").help("Shows the help command"),
command!([help, "commands"], "help_commands").help("help commands"),
command!([help, "proxy"], "help_proxy").help("help proxy"),
]
.into_iter()
}

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,29 @@
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 command_parser::{any, command, command::Command, parameter::*};
pub fn all() -> impl Iterator<Item = Command> {
(help::cmds())
.chain(system::cmds())
.chain(member::cmds())
.chain(config::cmds())
.chain(fun::cmds())
}

View file

@ -0,0 +1,43 @@
use super::*;
pub fn cmds() -> impl Iterator<Item = Command> {
let member = ["member", "m"];
let description = ["description", "desc"];
let privacy = ["privacy", "priv"];
let new = ["new", "n"];
[
command!([member, new, ("name", OpaqueString::SINGLE)], "member_new")
.help("Creates a new system member"),
command!([member, MemberRef], "member_show")
.help("Shows information about a member")
.value_flag("pt", Disable),
command!([member, MemberRef, description], "member_desc_show")
.help("Shows a member's description"),
command!(
[
member,
MemberRef,
description,
("description", OpaqueString::REMAINDER)
],
"member_desc_update"
)
.help("Changes a member's description"),
command!([member, MemberRef, privacy], "member_privacy_show")
.help("Displays a member's current privacy settings"),
command!(
[
member,
MemberRef,
privacy,
MemberPrivacyTarget,
("new_privacy_level", PrivacyLevel)
],
"member_privacy_update"
)
.help("Changes a member's privacy settings"),
command!([member, MemberRef, "soulscream"], "member_soulscream").show_in_suggestions(false),
]
.into_iter()
}

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,14 @@
use super::*;
pub fn cmds() -> impl Iterator<Item = Command> {
let system = ["system", "s"];
let new = ["new", "n"];
[
command!([system], "system_show").help("Shows information about your system"),
command!([system, new], "system_new").help("Creates a new system"),
command!([system, new, ("name", OpaqueString::SINGLE)], "system_new")
.help("Creates a new system"),
]
.into_iter()
}