Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cli option to read note from stdin #557

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion apps/cli/src/commands/bookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,27 @@ 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)")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we give the flag a better name to indicate that it's updating the notes? Maybe --note-stdin or something?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed I wondered about --stdin for add parameter as well. It's unclear what it's for. But I decided to be consistent. I'ld suggest to rename --stdin for both commands after the merge? Or rename it in parallel and I'll update + adapbt before merging this PR?

.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")
.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();

if (opts.stdin) {
lippoliv marked this conversation as resolved.
Show resolved Hide resolved
if (opts.note) {
printError(
`"--stdin" and "--note" cannot be used together`
)
return
}

opts.note = fs.readFileSync(0, "utf-8");
}

await api.bookmarks.updateBookmark
.mutate({
bookmarkId: id,
Expand Down