aboutsummaryrefslogtreecommitdiffstats
path: root/apps/cli/src/commands/lists.ts
diff options
context:
space:
mode:
authorkamtschatka <simon.schatka@gmx.at>2024-07-27 22:32:37 +0200
committerGitHub <noreply@github.com>2024-07-27 13:32:37 -0700
commit5e4decbe967ec28f9263bcb1d9907ee86262b91e (patch)
tree0a8f9764af4ef3bc2db7c5e993fef354782a2285 /apps/cli/src/commands/lists.ts
parenteb0a28ee6b1dd15fb459e0900f5e885ac5c92fec (diff)
downloadkarakeep-5e4decbe967ec28f9263bcb1d9907ee86262b91e.tar.zst
feature(cli): Allow updating tags/lists from CLI (#211)
* Improve the CLI #209 added the possibility to assign tags to bookmarks while creating added the possibility to assign a newly created to a list right away added the possibility to add and remove tags from bookmarks * minor tweaks --------- Co-authored-by: MohamedBassem <me@mbassem.com>
Diffstat (limited to 'apps/cli/src/commands/lists.ts')
-rw-r--r--apps/cli/src/commands/lists.ts38
1 files changed, 21 insertions, 17 deletions
diff --git a/apps/cli/src/commands/lists.ts b/apps/cli/src/commands/lists.ts
index 2f85ae7b..855624d6 100644
--- a/apps/cli/src/commands/lists.ts
+++ b/apps/cli/src/commands/lists.ts
@@ -62,29 +62,33 @@ listsCmd
.catch(printError(`Failed to delete list with id "${id}"`));
});
+export async function addToList(listId: string, bookmarkId: string) {
+ const api = getAPIClient();
+
+ await api.lists.addToList
+ .mutate({
+ listId,
+ bookmarkId,
+ })
+ .then(
+ printSuccess(
+ `Successfully added bookmark "${bookmarkId}" to list with id "${listId}"`,
+ ),
+ )
+ .catch(
+ printError(
+ `Failed to add bookmark "${bookmarkId}" to list with id "${listId}"`,
+ ),
+ );
+}
+
listsCmd
.command("add-bookmark")
.description("add a bookmark to list")
.requiredOption("--list <id>", "the id of the list")
.requiredOption("--bookmark <bookmark>", "the id of the bookmark")
.action(async (opts) => {
- const api = getAPIClient();
-
- await api.lists.addToList
- .mutate({
- listId: opts.list,
- bookmarkId: opts.bookmark,
- })
- .then(
- printSuccess(
- `Successfully added bookmark "${opts.bookmark}" to list with id "${opts.list}"`,
- ),
- )
- .catch(
- printError(
- `Failed to add bookmark "${opts.bookmark}" to list with id "${opts.list}"`,
- ),
- );
+ await addToList(opts.list, opts.bookmark);
});
listsCmd