From dea889105bafa13da0bd93da2da0fbf0cf287cbf Mon Sep 17 00:00:00 2001 From: Oliver Lippert Date: Thu, 17 Oct 2024 12:08:41 +0200 Subject: [PATCH 1/2] feat: add option to read note from stdin like in "add" command Signed-off-by: Oliver Lippert --- apps/cli/src/commands/bookmarks.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/cli/src/commands/bookmarks.ts b/apps/cli/src/commands/bookmarks.ts index 1537740b9..82ce422aa 100644 --- a/apps/cli/src/commands/bookmarks.ts +++ b/apps/cli/src/commands/bookmarks.ts @@ -187,6 +187,7 @@ bookmarkCmd .description("update a bookmark") .option("--title ", "if set, the bookmark's title will be updated") .option("--note <note>", "if set, the bookmark's note will be updated") + .option("--stdin", "if set, the bookmark's note will be updated by stdin (not to be used with --note)") .option("--archive", "if set, the bookmark will be archived") .option("--no-archive", "if set, the bookmark will be unarchived") .option("--favourite", "if set, the bookmark will be favourited") @@ -194,6 +195,11 @@ bookmarkCmd .argument("<id>", "the id of the bookmark to update") .action(async (id, opts) => { const api = getAPIClient(); + + if (opts.stdin) { + opts.note = fs.readFileSync(0, "utf-8"); + } + await api.bookmarks.updateBookmark .mutate({ bookmarkId: id, From c28e661fd279175db97b73aabcc83e8ffd477455 Mon Sep 17 00:00:00 2001 From: Oliver Lippert <oliver@allesit.de> Date: Mon, 28 Oct 2024 09:15:11 +0100 Subject: [PATCH 2/2] stop users from using "--note" and "--stdin" at the same time Signed-off-by: Oliver Lippert <oliver@allesit.de> --- apps/cli/src/commands/bookmarks.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/cli/src/commands/bookmarks.ts b/apps/cli/src/commands/bookmarks.ts index 82ce422aa..60765c614 100644 --- a/apps/cli/src/commands/bookmarks.ts +++ b/apps/cli/src/commands/bookmarks.ts @@ -186,7 +186,7 @@ bookmarkCmd .command("update") .description("update a bookmark") .option("--title <title>", "if set, the bookmark's title will be updated") - .option("--note <note>", "if set, the bookmark's note will be updated") + .option("--note <note>", "if set, the bookmark's note will be updated (not to be used with --stdin)") .option("--stdin", "if set, the bookmark's note will be updated by stdin (not to be used with --note)") .option("--archive", "if set, the bookmark will be archived") .option("--no-archive", "if set, the bookmark will be unarchived") @@ -197,6 +197,13 @@ bookmarkCmd const api = getAPIClient(); if (opts.stdin) { + if (opts.note) { + printError( + `"--stdin" and "--note" cannot be used together` + ) + return + } + opts.note = fs.readFileSync(0, "utf-8"); }