UNPKG

symfony-style-console

Version:

Use the style and utilities of the Symfony Console in Node.js

132 lines (131 loc) 3.8 kB
import { StringHash } from '../Helper/Helper'; import InputInterface from '../Input/InputInterface'; import OutputInterface, { OutputOptions } from '../Output/OutputInterface'; import { AnswerValidator } from '../Helper/Questionnaire'; import ProgressBar from '../Helper/ProgressBar'; import { TableCellInput, TableRowInput } from '../Helper/TableCellInterface'; import OutputStyle from './OutputStyle'; export default class SymfonyStyle extends OutputStyle { static LINE_LENGTH: number; static MAX_LINE_LENGTH: number; private input; private progressBar; private lineLength; private bufferedOutput; private questionnaire; constructor(input?: InputInterface, output?: OutputInterface); /** * Formats a message as a block of text. * * @param messages The message to write in the block * @param type The block type (in [] on first line) * @param style The style to apply to the whole block * @param prefix The prefix for the block * @param padding Whether to add vertical padding * @param escape Whether to escape the messages */ block(messages: string | string[], type: string, style: string, prefix?: string, padding?: boolean): void; /** * {@inheritdoc} */ title(message: string): void; /** * {@inheritdoc} */ section(message: string): void; /** * {@inheritdoc} */ listing(elements: string[]): void; /** * {@inheritdoc} */ text(message: string | string[]): void; /** * Formats a command comment. * * @param message */ comment(message: string | string[]): void; /** * {@inheritdoc} */ success(message: string | string[]): void; /** * {@inheritdoc} */ error(message: string | string[]): void; /** * {@inheritdoc} */ warning(message: string | string[]): void; /** * {@inheritdoc} */ note(message: string | string[]): void; /** * {@inheritdoc} */ caution(message: string | string[]): void; /** * {@inheritdoc} */ table(headers: TableCellInput[] | TableCellInput[][], rows: TableRowInput[]): void; /** * {@inheritdoc} */ ask(question: string, defaultAnswer?: string, validator?: AnswerValidator): Promise<any>; /** * {@inheritdoc} */ askHidden(question: string, validator?: AnswerValidator): Promise<string>; /** * {@inheritdoc} */ confirm(question: string, defaultAnswer?: boolean): Promise<boolean>; /** * {@inheritdoc} */ choice(question: string, choices: StringHash, defaultAnswer?: string): Promise<string>; /** * {@inheritdoc} */ progressStart(max?: number): void; /** * {@inheritdoc} */ progressAdvance(step?: number): void; /** * {@inheritdoc} */ progressSet(step: number): void; /** * {@inheritdoc} */ progressFinish(): void; /** * {@inheritdoc} */ protected createProgressBar(max?: number): ProgressBar; /** * {@inheritdoc} */ writeln(messages: string | string[], type?: OutputOptions): void; /** * {@inheritdoc} */ write(messages: string | string[], newline?: boolean, type?: OutputOptions): void; /** * {@inheritdoc} */ newLine(count?: number): void; /** * @return ProgressBar */ protected getProgressBar(): ProgressBar; protected autoPrependBlock(): void; protected autoPrependText(): void; protected reduceBuffer(messages: string | string[]): string[]; protected createBlock(messages: string[], type?: string, style?: string, prefix?: string, padding?: boolean, escape?: boolean): string[]; protected initQuestionnaire(): void; }