UNPKG

symfony-style-console

Version:

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

190 lines (189 loc) 5.54 kB
import { StringHash } from '../Helper/Helper'; import OutputInterface, { VERBOSITY_LEVEL, OutputOptions } from '../Output/OutputInterface'; import OutputFormatterInterface from '../Formatter/OutputFormatterInterface'; import { TableCellInput, TableRowInput } from '../Helper/TableCellInterface'; import StyleInterface from './StyleInterface'; import ProgressBar from '../Helper/ProgressBar'; /** * Decorates output to add console style guide helpers. * * @author Kevin Bond <kevinbond@gmail.com> * * Original PHP class * * @author Florian Reuschel <florian@loilo.de> * * Port to TypeScript */ declare abstract class OutputStyle implements OutputInterface, StyleInterface { /** * The output to style. */ private output; /** * Create an OutputStyle instance. * * @param output The output to style */ constructor(output?: OutputInterface); /** * {@inheritdoc} */ abstract title(message: string): void; /** * {@inheritdoc} */ abstract section(message: string): void; /** * {@inheritdoc} */ abstract listing(elements: string[]): void; /** * {@inheritdoc} */ abstract text(message: string | string[]): void; /** * {@inheritdoc} */ abstract success(message: string | string[]): void; /** * {@inheritdoc} */ abstract error(message: string | string[]): void; /** * {@inheritdoc} */ abstract warning(message: string | string[]): void; /** * {@inheritdoc} */ abstract note(message: string | string[]): void; /** * {@inheritdoc} */ abstract caution(message: string | string[]): void; /** * {@inheritdoc} */ abstract table(headers: TableCellInput[] | TableCellInput[][], rows: TableRowInput[]): void; /** * {@inheritdoc} */ abstract ask(question: string, defaultValue?: string, validator?: (...args: any[]) => boolean): Promise<string>; /** * {@inheritdoc} */ abstract askHidden(question: string, validator?: (...args: any[]) => boolean): Promise<string>; /** * {@inheritdoc} */ abstract confirm(question: string, defaultValue?: boolean): Promise<boolean>; /** * {@inheritdoc} */ abstract choice(question: string, choices: StringHash, defaultValue?: string | number): Promise<string | number>; /** * {@inheritdoc} */ abstract progressStart(max?: number): void; /** * {@inheritdoc} */ abstract progressAdvance(step?: number): void; /** * {@inheritdoc} */ abstract progressSet(step: number): void; /** * {@inheritdoc} */ abstract progressFinish(): void; /** * Add newline(s). * * @param number count The number of newlines */ newLine(count?: number): void; /** * @param number max * * @return ProgressBar */ protected createProgressBar(max?: number): ProgressBar; /** * Writes a message to the output. * * @param messages The message as an array of lines or a single string * @param newline Whether to add a newline * @param type A bitmask of options (one of the OUTPUT or VERBOSITY constants), * 0 is considered the same as OUTPUT_NORMAL | VERBOSITY_NORMAL */ write(messages: string | string[], newline?: boolean, type?: OutputOptions): void; /** * Writes a message to the output and adds a newline at the end. * * @param messages The message as an array of lines of a single string * @param type A bitmask of options (one of the OUTPUT or VERBOSITY constants), * 0 is considered the same as OUTPUT_NORMAL | VERBOSITY_NORMAL */ writeln(messages: string | string[], type?: OutputOptions): void; /** * Sets the verbosity of the output. * * @param level The level of verbosity (one of the [[VERBOSITY_LEVEL]] constants) */ setVerbosity(level: VERBOSITY_LEVEL): void; /** * Gets the current verbosity of the output. * * @return number The current level of verbosity (one of the [[VERBOSITY_LEVEL]] constants) */ getVerbosity(): VERBOSITY_LEVEL; /** * Sets the decorated flag. * * @param decorated Whether to decorate the messages */ setDecorated(decorated: boolean): void; /** * Gets the decorated flag. * * @return True if the output will decorate messages, false otherwise */ isDecorated(): boolean; /** * Sets output formatter. * * @param The formatter to use */ setFormatter(formatter: OutputFormatterInterface): void; /** * Returns current output formatter instance. */ getFormatter(): OutputFormatterInterface; /** * Returns whether verbosity is quiet (-q). * * @return True if verbosity is set to [[VERBOSITY_QUIET]], false otherwise */ isQuiet(): boolean; /** * Returns whether verbosity is verbose (-v). * * @return True if verbosity is set to [[VERBOSITY_VERBOSE]], false otherwise */ isVerbose(): boolean; /** * Returns whether verbosity is very verbose (-vv). * * @return True if verbosity is set to [[VERBOSITY_VERY_VERBOSE]], false otherwise */ isVeryVerbose(): boolean; /** * Returns whether verbosity is debug (-vvv). * * @return True if verbosity is set to [[VERBOSITY_DEBUG]], false otherwise */ isDebug(): boolean; } export default OutputStyle;