feat(commands): add cs codegen to statically use params and flags in bot code, remove Any

This commit is contained in:
dusk 2025-01-21 12:36:54 +09:00
parent 0c012e98b5
commit 07e8a4851a
No known key found for this signature in database
20 changed files with 297 additions and 417 deletions

View file

@ -1,29 +1,25 @@
use command_parser::parameter;
use super::*;
pub fn cmds() -> impl Iterator<Item = Command> {
let cfg = ["config", "cfg"];
let autoproxy = ["autoproxy", "ap"];
let ap = tokens!(["config", "cfg"], ["autoproxy", "ap"]);
let ap_account = concat_tokens!(ap, [["account", "ac"]]);
let ap_timeout = concat_tokens!(ap, [["timeout", "tm"]]);
[
command!([cfg, autoproxy, ["account", "ac"]], "cfg_ap_account_show")
command!(ap_account => "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"),
command!(ap_account, Toggle => "cfg_ap_account_update")
.help("Toggles autoproxy for the account"),
command!(ap_timeout => "cfg_ap_timeout_show").help("Shows the autoproxy timeout"),
command!(ap_timeout, parameter::RESET => "cfg_ap_timeout_reset")
.help("Resets the autoproxy timeout"),
command!(ap_timeout, parameter::DISABLE => "cfg_ap_timeout_off")
.help("Disables the autoproxy timeout"),
command!(ap_timeout, ("timeout", OpaqueString) => "cfg_ap_timeout_update")
.help("Sets the autoproxy timeout"),
]
.into_iter()
}