aboutsummaryrefslogtreecommitdiffstats
path: root/apps/cli/src/commands/lists.ts
diff options
context:
space:
mode:
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