about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-06-09 15:45:09 +0200
committerMichael Vetter <jubalh@iodoru.org>2021-06-09 15:53:21 +0200
commit8ef35290bdde58c6a0e7231c1870152f946d78e0 (patch)
tree4bdebbc7cd297460d76603667b90a5993b7ad46b /src/command
parentd7adec69cefedce8949ead1309e9a8e56a8c4d8f (diff)
downloadprofani-tty-8ef35290bdde58c6a0e7231c1870152f946d78e0.tar.gz
Add command to show single bookmark details
`/bookmark list` lists all bookmarks with its details.
`/bookmark list <jid>` shows the details of a single bookmark.

Implement https://github.com/profanity-im/profanity/issues/1558
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_ac.c4
-rw-r--r--src/command/cmd_defs.c6
-rw-r--r--src/command/cmd_funcs.c15
3 files changed, 20 insertions, 5 deletions
diff --git a/src/command/cmd_ac.c b/src/command/cmd_ac.c
index 03c6e404..6b46d079 100644
--- a/src/command/cmd_ac.c
+++ b/src/command/cmd_ac.c
@@ -2206,6 +2206,10 @@ _bookmark_autocomplete(ProfWin* window, const char* const input, gboolean previo
     if (found) {
         return found;
     }
+    found = autocomplete_param_with_func(input, "/bookmark list", bookmark_find, previous, NULL);
+    if (found) {
+        return found;
+    }
 
     found = autocomplete_param_with_ac(input, "/bookmark", bookmark_ac, TRUE, previous);
     return found;
diff --git a/src/command/cmd_defs.c b/src/command/cmd_defs.c
index 0ebcf04f..a9621e0e 100644
--- a/src/command/cmd_defs.c
+++ b/src/command/cmd_defs.c
@@ -822,7 +822,7 @@ static struct cmd_t command_defs[] = {
               CMD_TAG_GROUPCHAT)
       CMD_SYN(
               "/bookmark",
-              "/bookmark list",
+              "/bookmark list [<jid>]",
               "/bookmark add [<room>] [nick <nick>] [password <password>] [name <roomname>] [autojoin on|off]",
               "/bookmark update <room> [nick <nick>] [password <password>] [name <roomname>] [autojoin on|off]",
               "/bookmark remove [<room>]",
@@ -836,7 +836,7 @@ static struct cmd_t command_defs[] = {
               "If you are in a chat room and no arguments are supplied to `/bookmark add`, autojoin is set to \"on\". "
               "There is also an autojoin ignore list in case you want to autojoin in many clients but not on Profanity. ")
       CMD_ARGS(
-              { "list", "List all bookmarks." },
+              { "list [<jid>]", "List all bookmarks. Or the details of one." },
               { "add [<room>]", "Add a bookmark, passing no room will bookmark the current room, setting autojoin to \"on\"." },
               { "remove [<room>]", "Remove a bookmark, passing no room will remove the bookmark for the current room, if one exists." },
               { "update <room>", "Update the properties associated with a bookmark." },
@@ -853,6 +853,8 @@ static struct cmd_t command_defs[] = {
               "/bookmark join room@example.com",
               "/bookmark update room@example.com nick NEWNICK autojoin on",
               "/bookmark ignore room@example.com",
+              "/bookmark list",
+              "/bookmark list room@example.com",
               "/bookmark remove room@example.com")
     },
 
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 901c81a3..8282a134 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -4661,9 +4661,18 @@ cmd_bookmark(ProfWin* window, const char* const command, gchar** args)
     }
 
     if (strcmp(cmd, "list") == 0) {
-        GList* bookmarks = bookmark_get_list();
-        cons_show_bookmarks(bookmarks);
-        g_list_free(bookmarks);
+        char* bookmark_jid = args[1];
+        if (bookmark_jid == NULL) {
+            // list all bookmarks
+            GList* bookmarks = bookmark_get_list();
+            cons_show_bookmarks(bookmarks);
+            g_list_free(bookmarks);
+        } else {
+             // list one bookmark
+            Bookmark *bookmark = bookmark_get_by_jid(bookmark_jid);
+            cons_show_bookmark(bookmark);
+        }
+
         return TRUE;
     }