import type { Command } from 'commander'; import type { CliContext } from '../cli/shared.js'; import { TwitterClient } from '../lib/twitter-client.js'; export function registerUnbookmarkCommand(program: Command, ctx: CliContext): void { program .command('unbookmark') .description('Remove bookmarked tweets') .argument('', 'Tweet IDs or URLs to remove from bookmarks') .action(async (tweetIdOrUrls: string[]) => { const opts = program.opts(); const timeoutMs = ctx.resolveTimeoutFromOptions(opts); const relayBaseUrl = ctx.resolveRelayBaseUrlFromOptions(opts); const profileName = ctx.resolveProfileNameFromOptions(opts); const client = new TwitterClient({ relayBaseUrl, profileName, timeoutMs }); let failures = 0; for (const input of tweetIdOrUrls) { const tweetId = ctx.extractTweetId(input); const result = await client.unbookmark(tweetId); if (result.success) { console.log(`${ctx.p('ok')}Removed bookmark for ${tweetId}`); } else { failures += 1; console.error(`${ctx.p('err')}Failed to remove bookmark for ${tweetId}: ${result.error}`); } } if (failures > 0) { process.exit(1); } }); }