organize config command definitions

This commit is contained in:
dawn 2026-01-17 10:35:23 +03:00
parent d1451a858d
commit bdf6a6c345
No known key found for this signature in database

View file

@ -4,80 +4,13 @@ use super::*;
pub fn cmds() -> impl IntoIterator<Item = Command> { pub fn cmds() -> impl IntoIterator<Item = Command> {
let cfg = ("config", ["cfg", "configure"]); let cfg = ("config", ["cfg", "configure"]);
let ap = tokens!(cfg, ("autoproxy", ["ap"]));
let base = [command!(cfg => "cfg_show").help("Shows the current configuration")];
let ap = tokens!(cfg, ("autoproxy", ["ap"]));
let ap_account = tokens!(ap, ("account", ["ac"])); let ap_account = tokens!(ap, ("account", ["ac"]));
let ap_timeout = tokens!(ap, ("timeout", ["tm"])); let ap_timeout = tokens!(ap, ("timeout", ["tm"]));
let autoproxy = [
let timezone = tokens!(cfg, ("timezone", ["zone", "tz"]));
let ping = tokens!(cfg, "ping");
let priv_ = ("private", ["priv"]);
let member_privacy = tokens!(cfg, priv_, ("member", ["mem"]));
let member_privacy_short = tokens!(cfg, "mp");
let group_privacy = tokens!(cfg, priv_, ("group", ["grp"]));
let group_privacy_short = tokens!(cfg, "gp");
let show = "show";
let show_private = tokens!(cfg, show, priv_);
let show_private_short = tokens!(cfg, "sp");
let proxy = ("proxy", ["px"]);
let proxy_case = tokens!(cfg, proxy, ("case", ["caps", "capitalize", "capitalise"]));
let proxy_error = tokens!(cfg, proxy, ("error", ["errors"]));
let proxy_error_short = tokens!(cfg, "pe");
let proxy_switch = tokens!(cfg, proxy, "switch");
let proxy_switch_short = tokens!(cfg, ("proxyswitch", ["ps"]));
let id = ("id", ["ids"]);
let split_id = tokens!(cfg, "split", id);
let split_id_short = tokens!(cfg, ("sid", ["sids"]));
let cap_id = tokens!(cfg, ("cap", ["caps", "capitalize", "capitalise"]), id);
let cap_id_short = tokens!(cfg, ("capid", ["capids"]));
let pad = ("pad", ["padding"]);
let pad_id = tokens!(cfg, pad, id);
let id_pad = tokens!(cfg, id, pad);
let id_pad_short = tokens!(cfg, ("idpad", ["padid", "padids"]));
let show_color = tokens!(cfg, show, ("color", ["colour", "colors", "colours"]));
let show_color_short = tokens!(
cfg,
(
"showcolor",
[
"showcolour",
"showcolors",
"showcolours",
"colorcode",
"colorhex"
]
)
);
let format = "format";
let name_format = tokens!(cfg, "name", format);
let name_format_short = tokens!(cfg, ("nameformat", ["nf"]));
let server = "server";
let server_name_format = tokens!(cfg, server, "name", format);
let server_format = tokens!(
cfg,
("server", ["servername"]),
("format", ["nameformat", "nf"])
);
let server_format_short = tokens!(
cfg,
("snf", ["servernf", "servernameformat", "snameformat"])
);
let limit_ = ("limit", ["lim"]);
let member_limit = tokens!(cfg, ("member", ["mem"]), limit_);
let group_limit = tokens!(cfg, ("group", ["grp"]), limit_);
let limit = tokens!(cfg, limit_);
[
command!(cfg => "cfg_show").help("Shows the current configuration"),
command!(ap_account => "cfg_ap_account_show") command!(ap_account => "cfg_ap_account_show")
.help("Shows autoproxy status for the account"), .help("Shows autoproxy status for the account"),
command!(ap_account, Toggle => "cfg_ap_account_update") command!(ap_account, Toggle => "cfg_ap_account_update")
@ -88,12 +21,28 @@ pub fn cmds() -> impl IntoIterator<Item = Command> {
.help("Disables the autoproxy timeout"), .help("Disables the autoproxy timeout"),
command!(ap_timeout, ("timeout", OpaqueString) => "cfg_ap_timeout_update") command!(ap_timeout, ("timeout", OpaqueString) => "cfg_ap_timeout_update")
.help("Sets the autoproxy timeout"), .help("Sets the autoproxy timeout"),
command!(timezone => "cfg_timezone_show").help("Shows the system timezone"), ];
command!(timezone, RESET => "cfg_timezone_reset").help("Resets the system timezone"),
command!(timezone, ("timezone", OpaqueString) => "cfg_timezone_update") let timezone_tokens = tokens!(cfg, ("timezone", ["zone", "tz"]));
let timezone = [
command!(timezone_tokens => "cfg_timezone_show").help("Shows the system timezone"),
command!(timezone_tokens, RESET => "cfg_timezone_reset").help("Resets the system timezone"),
command!(timezone_tokens, ("timezone", OpaqueString) => "cfg_timezone_update")
.help("Sets the system timezone"), .help("Sets the system timezone"),
command!(ping => "cfg_ping_show").help("Shows the ping setting"), ];
command!(ping, Toggle => "cfg_ping_update").help("Updates the ping setting"),
let ping_tokens = tokens!(cfg, "ping");
let ping = [
command!(ping_tokens => "cfg_ping_show").help("Shows the ping setting"),
command!(ping_tokens, Toggle => "cfg_ping_update").help("Updates the ping setting"),
];
let priv_ = ("private", ["priv"]);
let member_privacy = tokens!(cfg, priv_, ("member", ["mem"]));
let member_privacy_short = tokens!(cfg, "mp");
let group_privacy = tokens!(cfg, priv_, ("group", ["grp"]));
let group_privacy_short = tokens!(cfg, "gp");
let privacy = [
command!(member_privacy => "cfg_member_privacy_show") command!(member_privacy => "cfg_member_privacy_show")
.help("Shows the default privacy for new members"), .help("Shows the default privacy for new members"),
command!(member_privacy, Toggle => "cfg_member_privacy_update") command!(member_privacy, Toggle => "cfg_member_privacy_update")
@ -110,6 +59,12 @@ pub fn cmds() -> impl IntoIterator<Item = Command> {
.help("Shows the default privacy for new groups"), .help("Shows the default privacy for new groups"),
command!(group_privacy_short, Toggle => "cfg_group_privacy_update") command!(group_privacy_short, Toggle => "cfg_group_privacy_update")
.help("Sets the default privacy for new groups"), .help("Sets the default privacy for new groups"),
];
let show = "show";
let show_private = tokens!(cfg, show, priv_);
let show_private_short = tokens!(cfg, "sp");
let private_info = [
command!(show_private => "cfg_show_private_info_show") command!(show_private => "cfg_show_private_info_show")
.help("Shows whether private info is shown"), .help("Shows whether private info is shown"),
command!(show_private, Toggle => "cfg_show_private_info_update") command!(show_private, Toggle => "cfg_show_private_info_update")
@ -118,6 +73,15 @@ pub fn cmds() -> impl IntoIterator<Item = Command> {
.help("Shows whether private info is shown"), .help("Shows whether private info is shown"),
command!(show_private_short, Toggle => "cfg_show_private_info_update") command!(show_private_short, Toggle => "cfg_show_private_info_update")
.help("Toggles showing private info"), .help("Toggles showing private info"),
];
let proxy = ("proxy", ["px"]);
let proxy_case = tokens!(cfg, proxy, ("case", ["caps", "capitalize", "capitalise"]));
let proxy_error = tokens!(cfg, proxy, ("error", ["errors"]));
let proxy_error_short = tokens!(cfg, "pe");
let proxy_switch = tokens!(cfg, proxy, "switch");
let proxy_switch_short = tokens!(cfg, ("proxyswitch", ["ps"]));
let proxy_settings = [
command!(proxy_case => "cfg_case_sensitive_proxy_tags_show") command!(proxy_case => "cfg_case_sensitive_proxy_tags_show")
.help("Shows whether proxy tags are case-sensitive"), .help("Shows whether proxy tags are case-sensitive"),
command!(proxy_case, Toggle => "cfg_case_sensitive_proxy_tags_update") command!(proxy_case, Toggle => "cfg_case_sensitive_proxy_tags_update")
@ -130,6 +94,25 @@ pub fn cmds() -> impl IntoIterator<Item = Command> {
.help("Shows whether proxy error messages are enabled"), .help("Shows whether proxy error messages are enabled"),
command!(proxy_error_short, Toggle => "cfg_proxy_error_message_update") command!(proxy_error_short, Toggle => "cfg_proxy_error_message_update")
.help("Toggles proxy error messages"), .help("Toggles proxy error messages"),
command!(proxy_switch => "cfg_proxy_switch_show").help("Shows the proxy switch behavior"),
command!(proxy_switch, ProxySwitchAction => "cfg_proxy_switch_update")
.help("Sets the proxy switch behavior"),
command!(proxy_switch_short => "cfg_proxy_switch_show")
.help("Shows the proxy switch behavior"),
command!(proxy_switch_short, ProxySwitchAction => "cfg_proxy_switch_update")
.help("Sets the proxy switch behavior"),
];
let id = ("id", ["ids"]);
let split_id = tokens!(cfg, "split", id);
let split_id_short = tokens!(cfg, ("sid", ["sids"]));
let cap_id = tokens!(cfg, ("cap", ["caps", "capitalize", "capitalise"]), id);
let cap_id_short = tokens!(cfg, ("capid", ["capids"]));
let pad = ("pad", ["padding"]);
let pad_id = tokens!(cfg, pad, id);
let id_pad = tokens!(cfg, id, pad);
let id_pad_short = tokens!(cfg, ("idpad", ["padid", "padids"]));
let id_settings = [
command!(split_id => "cfg_hid_split_show").help("Shows whether IDs are split in lists"), command!(split_id => "cfg_hid_split_show").help("Shows whether IDs are split in lists"),
command!(split_id, Toggle => "cfg_hid_split_update").help("Toggles splitting IDs in lists"), command!(split_id, Toggle => "cfg_hid_split_update").help("Toggles splitting IDs in lists"),
command!(split_id_short => "cfg_hid_split_show") command!(split_id_short => "cfg_hid_split_show")
@ -152,6 +135,23 @@ pub fn cmds() -> impl IntoIterator<Item = Command> {
command!(id_pad_short => "cfg_hid_padding_show").help("Shows the ID padding for lists"), command!(id_pad_short => "cfg_hid_padding_show").help("Shows the ID padding for lists"),
command!(id_pad_short, ("padding", OpaqueString) => "cfg_hid_padding_update") command!(id_pad_short, ("padding", OpaqueString) => "cfg_hid_padding_update")
.help("Sets the ID padding for lists"), .help("Sets the ID padding for lists"),
];
let show_color = tokens!(cfg, show, ("color", ["colour", "colors", "colours"]));
let show_color_short = tokens!(
cfg,
(
"showcolor",
[
"showcolour",
"showcolors",
"showcolours",
"colorcode",
"colorhex"
]
)
);
let color_settings = [
command!(show_color => "cfg_card_show_color_hex_show") command!(show_color => "cfg_card_show_color_hex_show")
.help("Shows whether color hex codes are shown on cards"), .help("Shows whether color hex codes are shown on cards"),
command!(show_color, Toggle => "cfg_card_show_color_hex_update") command!(show_color, Toggle => "cfg_card_show_color_hex_update")
@ -160,13 +160,12 @@ pub fn cmds() -> impl IntoIterator<Item = Command> {
.help("Shows whether color hex codes are shown on cards"), .help("Shows whether color hex codes are shown on cards"),
command!(show_color_short, Toggle => "cfg_card_show_color_hex_update") command!(show_color_short, Toggle => "cfg_card_show_color_hex_update")
.help("Toggles showing color hex codes on cards"), .help("Toggles showing color hex codes on cards"),
command!(proxy_switch => "cfg_proxy_switch_show").help("Shows the proxy switch behavior"), ];
command!(proxy_switch, ProxySwitchAction => "cfg_proxy_switch_update")
.help("Sets the proxy switch behavior"), let format = "format";
command!(proxy_switch_short => "cfg_proxy_switch_show") let name_format = tokens!(cfg, "name", format);
.help("Shows the proxy switch behavior"), let name_format_short = tokens!(cfg, ("nameformat", ["nf"]));
command!(proxy_switch_short, ProxySwitchAction => "cfg_proxy_switch_update") let name_formatting = [
.help("Sets the proxy switch behavior"),
command!(name_format => "cfg_name_format_show").help("Shows the name format"), command!(name_format => "cfg_name_format_show").help("Shows the name format"),
command!(name_format, RESET => "cfg_name_format_reset").help("Resets the name format"), command!(name_format, RESET => "cfg_name_format_reset").help("Resets the name format"),
command!(name_format, ("format", OpaqueString) => "cfg_name_format_update") command!(name_format, ("format", OpaqueString) => "cfg_name_format_update")
@ -176,6 +175,20 @@ pub fn cmds() -> impl IntoIterator<Item = Command> {
.help("Resets the name format"), .help("Resets the name format"),
command!(name_format_short, ("format", OpaqueString) => "cfg_name_format_update") command!(name_format_short, ("format", OpaqueString) => "cfg_name_format_update")
.help("Sets the name format"), .help("Sets the name format"),
];
let server = "server";
let server_name_format = tokens!(cfg, server, "name", format);
let server_format = tokens!(
cfg,
("server", ["servername"]),
("format", ["nameformat", "nf"])
);
let server_format_short = tokens!(
cfg,
("snf", ["servernf", "servernameformat", "snameformat"])
);
let server_name_formatting = [
command!(server_name_format => "cfg_server_name_format_show") command!(server_name_format => "cfg_server_name_format_show")
.help("Shows the server name format"), .help("Shows the server name format"),
command!(server_name_format, RESET => "cfg_server_name_format_reset") command!(server_name_format, RESET => "cfg_server_name_format_reset")
@ -194,8 +207,28 @@ pub fn cmds() -> impl IntoIterator<Item = Command> {
.help("Resets the server name format"), .help("Resets the server name format"),
command!(server_format_short, ("format", OpaqueString) => "cfg_server_name_format_update") command!(server_format_short, ("format", OpaqueString) => "cfg_server_name_format_update")
.help("Sets the server name format"), .help("Sets the server name format"),
];
let limit_ = ("limit", ["lim"]);
let member_limit = tokens!(cfg, ("member", ["mem"]), limit_);
let group_limit = tokens!(cfg, ("group", ["grp"]), limit_);
let limit = tokens!(cfg, limit_);
let limits = [
command!(member_limit => "cfg_limits_update").help("Refreshes member/group limits"), command!(member_limit => "cfg_limits_update").help("Refreshes member/group limits"),
command!(group_limit => "cfg_limits_update").help("Refreshes member/group limits"), command!(group_limit => "cfg_limits_update").help("Refreshes member/group limits"),
command!(limit => "cfg_limits_update").help("Refreshes member/group limits"), command!(limit => "cfg_limits_update").help("Refreshes member/group limits"),
] ];
base.into_iter()
.chain(autoproxy)
.chain(timezone)
.chain(ping)
.chain(privacy)
.chain(private_info)
.chain(proxy_settings)
.chain(id_settings)
.chain(color_settings)
.chain(name_formatting)
.chain(server_name_formatting)
.chain(limits)
} }