feat: support relay profile selection
CI / test (push) Successful in 10m2s

This commit is contained in:
2026-06-24 18:30:24 +09:00
parent 7a036e244d
commit 3f370cc4b6
24 changed files with 160 additions and 25 deletions
+11
View File
@@ -17,6 +17,7 @@ import type { TweetData } from '../lib/twitter-client.js';
export type BirdConfig = {
relayBaseUrl?: string;
profileName?: string;
timeoutMs?: number;
quoteDepth?: number;
};
@@ -44,6 +45,7 @@ export type CliContext = {
applyOutputFromCommand: (command: Command) => void;
resolveTimeoutFromOptions: (options: { timeout?: string | number }) => number | undefined;
resolveQuoteDepthFromOptions: (options: { quoteDepth?: string | number }) => number | undefined;
resolveProfileNameFromOptions: (opts: ProfileOptions) => string | undefined;
resolveRelayBaseUrlFromOptions: (opts: RelayOptions) => string | undefined;
loadMedia: (opts: { media: string[]; alts: string[] }) => MediaSpec[];
printTweets: (tweets: TweetData[], opts?: { json?: boolean; emptyMessage?: string; showSeparator?: boolean }) => void;
@@ -138,6 +140,10 @@ type RelayOptions = {
relayBaseUrl?: string;
};
type ProfileOptions = {
profileName?: string;
};
export function createCliContext(normalizedArgs: string[], env: NodeJS.ProcessEnv = process.env): CliContext {
const isTty = process.stdout.isTTY;
let output: OutputConfig = resolveOutputConfigFromArgv(normalizedArgs, env, isTty);
@@ -235,6 +241,10 @@ export function createCliContext(normalizedArgs: string[], env: NodeJS.ProcessEn
return opts.relayBaseUrl || config.relayBaseUrl || env.TWITTER_RELAY_BASE_URL;
}
function resolveProfileNameFromOptions(opts: ProfileOptions): string | undefined {
return opts.profileName || env.BIRD_PROFILE_NAME || config.profileName;
}
function loadMedia(opts: { media: string[]; alts: string[] }): MediaSpec[] {
if (opts.media.length === 0) {
return [];
@@ -367,6 +377,7 @@ export function createCliContext(normalizedArgs: string[], env: NodeJS.ProcessEn
applyOutputFromCommand,
resolveTimeoutFromOptions,
resolveQuoteDepthFromOptions,
resolveProfileNameFromOptions,
resolveRelayBaseUrlFromOptions,
loadMedia,
printTweets,