test(cli): always print tweet URL

This commit is contained in:
Peter Steinberger
2025-12-26 22:04:08 +01:00
parent 1007d051e4
commit a3d1ba29f7
3 changed files with 21 additions and 2 deletions
+3 -2
View File
@@ -21,6 +21,7 @@ import { extractTweetId } from './lib/extract-tweet-id.js';
import { mentionsQueryFromUserOption, normalizeHandle } from './lib/normalize-handle.js';
import {
formatStatsLine,
formatTweetUrlLine,
labelPrefix,
type OutputConfig,
resolveOutputConfigFromArgv,
@@ -403,7 +404,7 @@ program
if (result.success) {
console.log(`${p('ok')}Tweet posted successfully!`);
console.log(`${l('url')}https://x.com/i/status/${result.tweetId}`);
console.log(formatTweetUrlLine(result.tweetId, output));
} else {
console.error(`${p('err')}Failed to post tweet: ${result.error}`);
process.exit(1);
@@ -464,7 +465,7 @@ program
if (result.success) {
console.log(`${p('ok')}Reply posted successfully!`);
console.log(`${l('url')}https://x.com/i/status/${result.tweetId}`);
console.log(formatTweetUrlLine(result.tweetId, output));
} else {
console.error(`${p('err')}Failed to post reply: ${result.error}`);
process.exit(1);
+8
View File
@@ -76,3 +76,11 @@ export function formatStatsLine(
if (!cfg.emoji) return `Likes ${likeCount} Retweets ${retweetCount} Replies ${replyCount}`;
return `❤️ ${likeCount} 🔁 ${retweetCount} 💬 ${replyCount}`;
}
export function formatTweetUrl(tweetId: string): string {
return `https://x.com/i/status/${tweetId}`;
}
export function formatTweetUrlLine(tweetId: string, cfg: OutputConfig): string {
return `${labelPrefix('url', cfg)}${formatTweetUrl(tweetId)}`;
}