import { WriteStream } from 'fs'; import { Argv } from 'yargs'; import { CLIError } from './core/exceptions'; import { CommandHelp, GeneralHelp } from './help'; export type Options = { format: string; }; export type TableStyle = 'compact' | 'minimal' | 'markdown'; export type TableCellAlignment = 'left' | 'center' | 'right'; export type TableOptions = { head?: string[]; headFormat?: (text: string) => string; style?: TableStyle; widths?: (number | null)[]; alignments?: TableCellAlignment[]; wrap?: boolean; truncate?: boolean; }; export type TextLayoutOptions = { style: (text: string) => string; padding: [number, number, number, number]; alignment: TableCellAlignment; removeIndent: boolean; }; export type OutputColumn = { text: string; options?: Partial; }; export type Style = (text: string) => string; export interface IUIComposer { configure(opts: { indent?: number; width?: number }): void; header(name: string, style?: Style): Promise; skip(lines?: number): Promise; markdown(src: string): string; line(value: string): Promise; text(text: string): Promise; rows(data: OutputColumn[][]): Promise; figlet(text: string): Promise; table(value: string[][], options?: TableOptions): Promise; section(name: string, wrapper?: (builder: IUIComposer) => Promise, style?: Style): Promise; wrap(wrapper: (builder: IUIComposer) => Promise, verticalPadding?: number): Promise; error(error: Error): Promise; json(value: any, style?: TableStyle): Promise; get(): Promise; clear(): Promise; } export type FormatData = { help?: GeneralHelp | CommandHelp; text: string[]; errors: Error[]; value?: any; }; export interface IOutputFormat { registerOptions(options: Argv): Argv; format(data: FormatData, options: O): Promise; } export interface IOutput { registerFormat(name: string, format: IOutputFormat): void; help(value: CommandHelp | GeneralHelp): Promise; text(value: string): Promise; value(value: T): Promise; error(value: CLIError): Promise; compose(builder: (ui: IUIComposer) => Promise): Promise; flush(stream: WriteStream): Promise; }