From 5e4decbe967ec28f9263bcb1d9907ee86262b91e Mon Sep 17 00:00:00 2001 From: kamtschatka Date: Sat, 27 Jul 2024 22:32:37 +0200 Subject: 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 --- apps/cli/src/commands/lists.ts | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'apps/cli/src/commands/lists.ts') 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 ", "the id of the list") .requiredOption("--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 -- cgit v1.2.3-70-g09d2