This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user