rcgit

/ karakeep

Commit f6ecef88

SHA f6ecef8832a8604eb2269086cb7b819c02c4e8ed
Author MohamedBassem <me at mbassem dot com>
Author Date 2024-07-27 20:47 +0000
Committer MohamedBassem <me at mbassem dot com>
Commit Date 2024-07-27 20:47 +0000
Parent(s) 4f661c410d01 (diff)
Tree 772920a807d8

patch snapshot

cli: Extract tag management into separate subcommand
File + - Graph
M apps/cli/package.json +1 -1
M apps/cli/src/commands/bookmarks.ts +19 -20
2 file(s) changed, 20 insertions(+), 21 deletions(-)

apps/cli/package.json

diff --git a/apps/cli/package.json b/apps/cli/package.json
index 7bdf836f..ef0fc465 100644
--- a/apps/cli/package.json
+++ b/apps/cli/package.json
@@ -1,7 +1,7 @@
 {
   "$schema": "https://json.schemastore.org/package.json",
   "name": "@hoarderapp/cli",
-  "version": "0.13.6",
+  "version": "0.13.7",
   "description": "Command Line Interface (CLI) for Hoarder",
   "license": "GNU Affero General Public License version 3",
   "keywords": [

apps/cli/src/commands/bookmarks.ts

diff --git a/apps/cli/src/commands/bookmarks.ts b/apps/cli/src/commands/bookmarks.ts
index 51dd037b..1537740b 100644
--- a/apps/cli/src/commands/bookmarks.ts
+++ b/apps/cli/src/commands/bookmarks.ts
@@ -191,6 +191,24 @@ bookmarkCmd
   .option("--no-archive", "if set, the bookmark will be unarchived")
   .option("--favourite", "if set, the bookmark will be favourited")
   .option("--no-favourite", "if set, the bookmark will be unfavourited")
+  .argument("<id>", "the id of the bookmark to update")
+  .action(async (id, opts) => {
+    const api = getAPIClient();
+    await api.bookmarks.updateBookmark
+      .mutate({
+        bookmarkId: id,
+        archived: opts.archive,
+        favourited: opts.favourite,
+        title: opts.title,
+        note: opts.note,
+      })
+      .then(printObject)
+      .catch(printError(`Failed to update bookmark with id "${id}"`));
+  });
+
+bookmarkCmd
+  .command("update-tags")
+  .description("update the tags of a bookmark")
   .option(
     "--add-tag <tag>",
     "if set, this tag will be added to the bookmark. Specify multiple times to add multiple tags",
@@ -203,28 +221,9 @@ bookmarkCmd
     collect<string>,
     [],
   )
-  .argument("<id>", "the id of the bookmark to get")
+  .argument("<id>", "the id of the bookmark to update")
   .action(async (id, opts) => {
-    const api = getAPIClient();
     await updateTags(opts.addTag, opts.removeTag, id);
-
-    if (
-      "archive" in opts ||
-      "favourite" in opts ||
-      "title" in opts ||
-      "note" in opts
-    ) {
-      await api.bookmarks.updateBookmark
-        .mutate({
-          bookmarkId: id,
-          archived: opts.archive,
-          favourited: opts.favourite,
-          title: opts.title,
-          note: opts.note,
-        })
-        .then(printObject)
-        .catch(printError(`Failed to update bookmark with id "${id}"`));
-    }
   });
 
 bookmarkCmd