mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-07 06:17:55 +00:00
refactor: separate commands into command_parser, command_definitions crates
This commit is contained in:
parent
4f390e2a14
commit
0c012e98b5
33 changed files with 464 additions and 378 deletions
1
crates/command_definitions/src/admin.rs
Normal file
1
crates/command_definitions/src/admin.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/api.rs
Normal file
1
crates/command_definitions/src/api.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/autoproxy.rs
Normal file
1
crates/command_definitions/src/autoproxy.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/checks.rs
Normal file
1
crates/command_definitions/src/checks.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/commands.rs
Normal file
1
crates/command_definitions/src/commands.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
29
crates/command_definitions/src/config.rs
Normal file
29
crates/command_definitions/src/config.rs
Normal 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()
|
||||
}
|
||||
1
crates/command_definitions/src/dashboard.rs
Normal file
1
crates/command_definitions/src/dashboard.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/debug.rs
Normal file
1
crates/command_definitions/src/debug.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
9
crates/command_definitions/src/fun.rs
Normal file
9
crates/command_definitions/src/fun.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
use super::*;
|
||||
|
||||
pub fn cmds() -> impl Iterator<Item = Command> {
|
||||
[
|
||||
command!(["thunder"], "fun_thunder"),
|
||||
command!(["meow"], "fun_meow"),
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
1
crates/command_definitions/src/group.rs
Normal file
1
crates/command_definitions/src/group.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
11
crates/command_definitions/src/help.rs
Normal file
11
crates/command_definitions/src/help.rs
Normal 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()
|
||||
}
|
||||
1
crates/command_definitions/src/import_export.rs
Normal file
1
crates/command_definitions/src/import_export.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
29
crates/command_definitions/src/lib.rs
Normal file
29
crates/command_definitions/src/lib.rs
Normal 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())
|
||||
}
|
||||
43
crates/command_definitions/src/member.rs
Normal file
43
crates/command_definitions/src/member.rs
Normal 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()
|
||||
}
|
||||
1
crates/command_definitions/src/message.rs
Normal file
1
crates/command_definitions/src/message.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/misc.rs
Normal file
1
crates/command_definitions/src/misc.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/random.rs
Normal file
1
crates/command_definitions/src/random.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/server_config.rs
Normal file
1
crates/command_definitions/src/server_config.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
1
crates/command_definitions/src/switch.rs
Normal file
1
crates/command_definitions/src/switch.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
14
crates/command_definitions/src/system.rs
Normal file
14
crates/command_definitions/src/system.rs
Normal 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()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue