feat: implement switch commands

This commit is contained in:
dusk 2025-09-24 21:32:42 +03:00
parent 15191171f5
commit 10dd499835
No known key found for this signature in database
9 changed files with 85 additions and 45 deletions

View file

@ -26,8 +26,8 @@ pub fn all() -> impl Iterator<Item = Command> {
.chain(member::cmds())
.chain(config::cmds())
.chain(fun::cmds())
.map(|cmd| cmd.flag(("plaintext", ["pt"])))
.map(|cmd| cmd.flag(("raw", ["r"])))
.chain(switch::cmds())
.map(|cmd| cmd.flag(("plaintext", ["pt"])).flag(("raw", ["r"])))
}
pub const RESET: (&str, [&str; 2]) = ("reset", ["clear", "default"]);

View file

@ -1 +1,31 @@
use super::*;
pub fn cmds() -> impl Iterator<Item = Command> {
let switch = ("switch", ["sw"]);
let edit = ("edit", ["e", "replace"]);
let r#move = ("move", ["m", "shift", "offset"]);
let delete = ("delete", ["remove", "erase", "cancel", "yeet"]);
let copy = ("copy", ["add", "duplicate", "dupe"]);
let out = "out";
[
command!(switch, out => "switch_out"),
command!(switch, r#move, OpaqueString => "switch_move"), // TODO: datetime parsing
command!(switch, delete => "switch_delete").flag(("all", ["clear", "c"])),
command!(switch, edit, out => "switch_edit_out"),
command!(switch, edit, MemberRefs => "switch_edit")
.flag(("first", ["f"]))
.flag(("remove", ["r"]))
.flag(("append", ["a"]))
.flag(("prepend", ["p"])),
command!(switch, copy, MemberRefs => "switch_copy")
.flag(("first", ["f"]))
.flag(("remove", ["r"]))
.flag(("append", ["a"]))
.flag(("prepend", ["p"])),
command!(switch, ("commands", ["help"]) => "switch_commands"),
command!(switch, MemberRefs => "switch_do"),
]
.into_iter()
}