From 285e4b1f75d2bff608937bae1a05f0c13522d7db Mon Sep 17 00:00:00 2001 From: vaw Date: Mon, 13 Oct 2025 22:33:57 +0200 Subject: [PATCH] Add short command aliases --- docs/iamb.1 | 32 ++++++++++++++++---------------- src/commands.rs | 38 +++++++++++++++++++++++--------------- src/completions.rs | 21 ++++++++++++--------- 3 files changed, 51 insertions(+), 40 deletions(-) diff --git a/docs/iamb.1 b/docs/iamb.1 index 3f75ae73..6b3cdd69 100644 --- a/docs/iamb.1 +++ b/docs/iamb.1 @@ -50,20 +50,20 @@ version and quit. .Sh "GENERAL COMMANDS" .Bl -tag -width Ds -.It Sy ":chats" +.It Sy ":c[hats]" View a list of joined rooms and direct messages. .It Sy ":dms" View a list of direct messages. .It Sy ":logout [user id]" Log out of .Nm . -.It Sy ":rooms" +.It Sy ":r[ooms]" View a list of joined rooms. -.It Sy ":spaces" +.It Sy ":s[paces]" View a list of joined spaces. -.It Sy ":unreads" +.It Sy ":un[reads]" View a list of unread rooms. -.It Sy ":unreads clear" +.It Sy ":un[reads] clear" Mark all rooms as read. .It Sy ":mentions" View a list of rooms with mentions of the current user. @@ -96,30 +96,30 @@ Request a new verification with the specified user. .Sh "MESSAGE COMMANDS" .Bl -tag -width Ds -.It Sy ":download [path]" +.It Sy ":d[ownload] [path]" Download an attachment from the selected message and save it to the optional path. -.It Sy ":open [path]" +.It Sy ":o[pen] [path]" Download and then open an attachment, or open a link in a message. -.It Sy ":edit" +.It Sy ":e[dit]" Edit the selected message. -.It Sy ":editor" +.It Sy ":ed[itor]" Open an external .Ev $EDITOR to compose a message. -.It Sy ":react [shortcode]" +.It Sy ":r[ea]c[t] [shortcode]" React to the selected message with an Emoji. -.It Sy ":unreact [shortcode]" +.It Sy ":unr[eact] [shortcode]" Remove your reaction from the selected message. When no arguments are given, remove all of your reactions from the message. -.It Sy ":redact [reason]" +.It Sy ":red[act] [reason]" Redact the selected message with the optional reason. -.It Sy ":reply" +.It Sy ":rep[ly]" Reply to the selected message. -.It Sy ":cancel" +.It Sy ":ca[ncel]" Cancel the currently drafted message including replies. .It Sy ":replied" Go to the message the current message replied to. -.It Sy ":upload [path]" +.It Sy ":u[pload] [path]" Upload an attachment and send it to the currently selected room. .El @@ -154,7 +154,7 @@ Reject a knock from the specified user to the currently focused room with an opt Send an invitation to a user to join the currently focused room with an optional reason. .It Sy ":leave" Leave the currently focused room. -.It Sy ":members" +.It Sy ":me[mbers]" View a list of members of the currently focused room. .It Sy ":room name set [name]" Set the name of the currently focused room. diff --git a/src/commands.rs b/src/commands.rs index 5db66deb..32d2b1a2 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -965,7 +965,7 @@ fn iamb_logout(desc: CommandDescription, ctx: &mut ProgContext) -> ProgResult { pub fn add_iamb_commands(cmds: &mut ProgramCommands) { cmds.add_command(ProgramCommand { name: "cancel".into(), - aliases: vec![], + aliases: vec!["ca".into()], f: iamb_cancel, }); cmds.add_command(ProgramCommand { @@ -975,17 +975,25 @@ pub fn add_iamb_commands(cmds: &mut ProgramCommands) { }); cmds.add_command(ProgramCommand { name: "chats".into(), - aliases: vec![], + aliases: vec!["c".into()], f: iamb_chats, }); cmds.add_command(ProgramCommand { name: "dms".into(), aliases: vec![], f: iamb_dms }); cmds.add_command(ProgramCommand { name: "download".into(), - aliases: vec![], + aliases: vec!["d".into()], f: iamb_download, }); - cmds.add_command(ProgramCommand { name: "open".into(), aliases: vec![], f: iamb_open }); - cmds.add_command(ProgramCommand { name: "edit".into(), aliases: vec![], f: iamb_edit }); + cmds.add_command(ProgramCommand { + name: "open".into(), + aliases: vec!["o".into()], + f: iamb_open, + }); + cmds.add_command(ProgramCommand { + name: "edit".into(), + aliases: vec!["e".into()], + f: iamb_edit, + }); cmds.add_command(ProgramCommand { name: "follow".into(), aliases: vec![], @@ -1015,22 +1023,22 @@ pub fn add_iamb_commands(cmds: &mut ProgramCommands) { }); cmds.add_command(ProgramCommand { name: "members".into(), - aliases: vec![], + aliases: vec!["me".into()], f: iamb_members, }); cmds.add_command(ProgramCommand { name: "react".into(), - aliases: vec![], + aliases: vec!["rc".into(), "reac".into(), "rct".into()], f: iamb_react, }); cmds.add_command(ProgramCommand { name: "redact".into(), - aliases: vec![], + aliases: vec!["red".into()], f: iamb_redact, }); cmds.add_command(ProgramCommand { name: "reply".into(), - aliases: vec![], + aliases: vec!["rep".into()], f: iamb_reply, }); cmds.add_command(ProgramCommand { @@ -1040,7 +1048,7 @@ pub fn add_iamb_commands(cmds: &mut ProgramCommands) { }); cmds.add_command(ProgramCommand { name: "rooms".into(), - aliases: vec![], + aliases: vec!["r".into()], f: iamb_rooms, }); cmds.add_command(ProgramCommand { name: "room".into(), aliases: vec![], f: iamb_room }); @@ -1051,12 +1059,12 @@ pub fn add_iamb_commands(cmds: &mut ProgramCommands) { }); cmds.add_command(ProgramCommand { name: "spaces".into(), - aliases: vec![], + aliases: vec!["s".into()], f: iamb_spaces, }); cmds.add_command(ProgramCommand { name: "unreads".into(), - aliases: vec![], + aliases: vec!["un".into()], f: iamb_unreads, }); cmds.add_command(ProgramCommand { @@ -1067,12 +1075,12 @@ pub fn add_iamb_commands(cmds: &mut ProgramCommands) { cmds.add_command(ProgramCommand { name: "self".into(), aliases: vec![], f: iamb_self }); cmds.add_command(ProgramCommand { name: "unreact".into(), - aliases: vec![], + aliases: vec!["unr".into()], f: iamb_unreact, }); cmds.add_command(ProgramCommand { name: "upload".into(), - aliases: vec![], + aliases: vec!["u".into()], f: iamb_upload, }); cmds.add_command(ProgramCommand { @@ -1087,7 +1095,7 @@ pub fn add_iamb_commands(cmds: &mut ProgramCommands) { }); cmds.add_command(ProgramCommand { name: "editor".into(), - aliases: vec![], + aliases: vec!["ed".into()], f: iamb_editor, }); cmds.add_command(ProgramCommand { diff --git a/src/completions.rs b/src/completions.rs index c429c6a4..dc68686c 100644 --- a/src/completions.rs +++ b/src/completions.rs @@ -561,11 +561,11 @@ fn complete_cmdarg( "logout" => complete_iamb_logout(args, store), - "react" if args.len() == 1 => complete_emoji(&args[0], store), - "react" => vec![], + "react" | "rc" | "reac" | "rct" if args.len() == 1 => complete_emoji(&args[0], store), + "react" | "rc" | "reac" | "rct" => vec![], // The redaction reason is free text - "redact" => vec![], + "redact" | "red" => vec![], "room" => complete_iamb_room(args, store), @@ -574,12 +574,12 @@ fn complete_cmdarg( "space" => complete_iamb_space(args, store), // TODO: Check whether we can get the id of the focused message to improve completion - "unreact" if args.len() == 1 => complete_emoji(&args[0], store), - "unreact" => vec![], + "unreact" | "unr" if args.len() == 1 => complete_emoji(&args[0], store), + "unreact" | "unr" => vec![], - "unreads" => complete_iamb_unreads(args), + "unreads" | "un" => complete_iamb_unreads(args), - "upload" | "download" | "open" => { + "upload" | "u" | "download" | "d" | "open" | "o" => { if input.get_char_at_cursor(cursor) == Some('"') { // Use the escaped instead of the qouted filename. let mut args = args; @@ -593,8 +593,11 @@ fn complete_cmdarg( "verify" => complete_iamb_verify(args, store), // These have no arguments - "cancel" | "chats" | "dms" | "editor" | "edit" | "forget" | "leave" | "members" | - "mentions" | "replied" | "reply" | "rooms" | "spaces" | "welcome" => vec![], + "cancel" | "ca" | "chats" | "c" | "dms" | "editor" | "ed" | "edit" | "e" | "forget" | + "leave" | "members" | "me" | "mentions" | "replied" | "reply" | "rep" | "rooms" | "r" | + "spaces" | "s" | "welcome" => { + vec![] + }, "abo" | "aboveleft" | "bel" | "belowright" | "hor" | "horizontal" | "lefta" | "leftabove" | "rightb" | "rightbelow" | "tab" | "vert" | "vertical" => {