symfony-style-console
Version:
Use the style and utilities of the Symfony Console in Node.js
110 lines (109 loc) • 3.6 kB
TypeScript
import OutputFormatterInterface from '../Formatter/OutputFormatterInterface';
import OutputInterface, { OutputOptions, VERBOSITY_LEVEL } from './OutputInterface';
/**
* Base class for output classes.
*
* There are five levels of verbosity:
*
* * normal: no option passed (normal output)
* * verbose: `-v` (more output)
* * very verbose: `-vv` (highly extended output)
* * debug: `-vvv` (all debug output)
* * quiet: `-q` (no output)
*
* @author Fabien Potencier <fabien@symfony.com>
*
* Original PHP class
*
* @author Florian Reuschel <florian@loilo.de>
*
* Port to TypeScript
*/
declare abstract class Output implements OutputInterface {
private formatter;
private verbosity;
constructor(verbosity?: VERBOSITY_LEVEL, decorated?: boolean, formatter?: OutputFormatterInterface);
/**
* Sets the decorated flag.
*
* @param decorated Whether to decorate the messages
*/
setDecorated(decorated: boolean): void;
/**
* Gets the decorated flag.
*
* @return boolean true if the output will decorate messages, false otherwise
*/
isDecorated(): boolean;
/**
* Sets output formatter.
*
* @param formatter
*/
setFormatter(formatter: OutputFormatterInterface): void;
/**
* Returns current output formatter instance.
*/
getFormatter(): OutputFormatterInterface;
/**
* Sets the verbosity of the output.
*
* @param number level The level of verbosity (one of the VERBOSITY constants)
*/
setVerbosity(level: VERBOSITY_LEVEL): void;
/**
* Gets the current verbosity of the output.
*
* @return number The current level of verbosity (one of the VERBOSITY constants)
*/
getVerbosity(): VERBOSITY_LEVEL;
/**
* Returns whether verbosity is quiet (-q).
*
* @return bool true if verbosity is set to VERBOSITY_QUIET, false otherwise
*/
isQuiet(): boolean;
/**
* Returns whether verbosity is verbose (-v).
*
* @return bool true if verbosity is set to VERBOSITY_VERBOSE, false otherwise
*/
isVerbose(): boolean;
/**
* Returns whether verbosity is very verbose (-vv).
*
* @return bool true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise
*/
isVeryVerbose(): boolean;
/**
* Returns whether verbosity is debug (-vvv).
*
* @return bool true if verbosity is set to VERBOSITY_DEBUG, false otherwise
*/
isDebug(): boolean;
/**
* 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 options 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[], options?: OutputOptions): void;
/**
* 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 options 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, options?: OutputOptions): void;
/**
* Writes a message to the output.
*
* @param message A message to write to the output
* @param newline Whether to add a newline or not
*/
protected abstract doWrite(message: string, newline: boolean): void;
}
export default Output;