/** * CLI Helper Functions */ import type { Config } from "../config/schema.js"; /** * Output format type */ export type OutputFormat = "pretty" | "json" | "ids-only" | "uuid" | "bibtex"; /** * CLI options interface */ export interface CliOptions { library?: string; logLevel?: "silent" | "info" | "debug"; config?: string; quiet?: boolean; verbose?: boolean; backup?: boolean; backupDir?: string; json?: boolean; idsOnly?: boolean; uuid?: boolean; bibtex?: boolean; attachmentsDir?: string; clipboard?: boolean; } /** * Read JSON input from file or stdin * @param file - File path (optional, defaults to stdin) * @returns JSON string */ export declare function readJsonInput(file?: string): Promise; /** * Parse JSON input * @param input - JSON string * @returns Parsed JSON object or array */ export declare function parseJsonInput(input: string): unknown; /** * Load config with CLI argument overrides * @param options - CLI options * @returns Config with overrides applied */ export declare function loadConfigWithOverrides(options: CliOptions): Promise; /** * Get output format from options * @param options - CLI options * @returns Output format * @throws Error if multiple formats specified */ export declare function getOutputFormat(options: CliOptions): OutputFormat; /** * Check if running in TTY * @returns True if stdin and stdout are TTY, or if REF_SKIP_TTY_CHECK is set * * @remarks * Set REF_SKIP_TTY_CHECK=1 environment variable to skip TTY check (for testing only) */ export declare function isTTY(): boolean; /** * Read identifiers from stdin (for non-TTY/pipeline mode). * Reads all lines, splits by whitespace/newlines, filters empty. * Returns empty array if stdin has no content. */ export declare function readIdentifiersFromStdin(): Promise; /** * Read a single identifier from stdin (for non-TTY/pipeline mode). * Returns the first non-empty line, or undefined if stdin is empty. */ export declare function readIdentifierFromStdin(): Promise; /** * Read confirmation from user (y/N) * @param prompt - Confirmation prompt message * @returns True if user confirmed (y/yes), false otherwise */ export declare function readConfirmation(prompt: string): Promise; /** * Choice option for readChoice prompt */ export interface Choice { label: string; value: string; } /** * Display a numbered choice prompt and return the selected value. * Output is written to stderr (keeping stdout clean for piping). * In non-TTY mode, returns the default choice value immediately. * * @param prompt - Question text displayed before the choices * @param choices - Available options to choose from * @param defaultIndex - Index of the default choice (used on empty input or non-TTY) * @returns The selected choice's value */ export declare function readChoice(prompt: string, choices: Choice[], defaultIndex?: number): Promise; /** * Read stdin content and split into inputs. * Used for reading identifiers from stdin. * @returns Array of input strings (split by whitespace) */ export declare function readStdinInputs(): Promise; /** * Read raw stdin content without splitting. * Used for reading file content (JSON, BibTeX, RIS) from stdin. * @returns Raw stdin content as string */ export declare function readStdinContent(): Promise; /** * Read raw stdin content as Buffer. * Used for reading binary file content (PDF) from stdin. * @returns Raw stdin content as Buffer */ export declare function readStdinBuffer(): Promise; /** * Standard exit codes for CLI commands */ export declare const ExitCode: { /** Success */ readonly SUCCESS: 0; /** General error (e.g., not found, validation failed) */ readonly ERROR: 1; /** Internal/unexpected error */ readonly INTERNAL_ERROR: 4; /** Interrupted by SIGINT */ readonly SIGINT: 130; }; /** * Set the process exit code without immediately exiting. * The process will exit with this code when the event loop completes. * @param code - Exit code (0 = success, non-zero = error) */ export declare function setExitCode(code: number): void; /** * Write error message to stderr and set exit code. * @param message - Error message to display * @param code - Exit code (defaults to 1) */ export declare function exitWithError(message: string, code?: number): void; /** * Write message to stderr and set exit code. * @param message - Message to display * @param code - Exit code */ export declare function exitWithMessage(message: string, code: number): void; /** * Resolve whether clipboard auto-copy is enabled. * * Priority (highest to lowest): * 1. CLI flag (--clipboard / --no-clipboard) * 2. Environment variable REFERENCE_MANAGER_CLIPBOARD_AUTO_COPY * 3. Config cli.tui.clipboardAutoCopy (only when isTui=true) * 4. Default: false */ export declare function resolveClipboardEnabled(options: CliOptions, config: Config, isTui: boolean): boolean; /** * Write output to stdout with optional clipboard copy. * @param output - Output text * @param clipboardEnabled - Whether to copy to clipboard * @param quiet - Whether to suppress stderr notifications */ export declare function writeOutputWithClipboard(output: string, clipboardEnabled: boolean, quiet: boolean): Promise; /** * Write output to stdout and set success exit code. * @param output - Output to display */ export declare function exitWithOutput(output: string): void; //# sourceMappingURL=helpers.d.ts.map