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 title option for adding bookmarks from the CLI #831

Merged
Merged
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
7 changes: 4 additions & 3 deletions apps/cli/src/commands/bookmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ bookmarkCmd
collect<string>,
[],
)
.option("--title <title>", "if set, this will be used as the bookmark's title")
.action(async (opts) => {
const api = getAPIClient();

Expand All @@ -81,15 +82,15 @@ bookmarkCmd
const promises = [
...opts.link.map((url) =>
api.bookmarks.createBookmark
.mutate({ type: BookmarkTypes.LINK, url })
.mutate({ type: BookmarkTypes.LINK, url, title: opts.title })
.then((bookmark: ZBookmark) => {
results.push(normalizeBookmark(bookmark));
})
.catch(printError(`Failed to add a link bookmark for url "${url}"`)),
),
...opts.note.map((text) =>
api.bookmarks.createBookmark
.mutate({ type: BookmarkTypes.TEXT, text })
.mutate({ type: BookmarkTypes.TEXT, text, title: opts.title })
.then((bookmark: ZBookmark) => {
results.push(normalizeBookmark(bookmark));
})
Expand All @@ -105,7 +106,7 @@ bookmarkCmd
const text = fs.readFileSync(0, "utf-8");
promises.push(
api.bookmarks.createBookmark
.mutate({ type: BookmarkTypes.TEXT, text })
.mutate({ type: BookmarkTypes.TEXT, text, title: opts.title })
.then((bookmark: ZBookmark) => {
results.push(normalizeBookmark(bookmark));
})
Expand Down
Loading