symfony-style-console
Version:
Use the style and utilities of the Symfony Console in Node.js
63 lines (62 loc) • 1.95 kB
TypeScript
/// <reference types="node" />
import Output from './Output';
import { VERBOSITY_LEVEL } from './OutputInterface';
import OutputFormatterInterface from '../Formatter/OutputFormatterInterface';
/**
* StreamOutput writes the output to a given stream.
*
* Usage:
*
* ```
* const output = new StreamOutput(process.stdout)
* ```
*
* As `StreamOutput` can use any stream, you can also use a file:
*
* ```
* const output = new StreamOutput(fs.createWriteStream('/path/to/output.log', { flags: 'a' }))
* ```
*
* @author Fabien Potencier <fabien@symfony.com>
*
* Original PHP class
*
* @author Florian Reuschel
*
* Port to TypeScript
*/
export default class StreamOutput extends Output {
private stream;
/**
* Creates a new StreamOutput instance
*
* @param stream A stream resource
* @param verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface)
* @param decorated Whether to decorate messages (null for auto-guessing)
* @param formatter Output formatter instance (null to use default OutputFormatter)
*
* @throws InvalidArgumentException When first argument is not a real stream
*/
constructor(stream: NodeJS.WritableStream, verbosity?: VERBOSITY_LEVEL, decorated?: boolean, formatter?: OutputFormatterInterface);
/**
* Gets the stream attached to this StreamOutput instance.
*
* @return A stream resource
*/
getStream(): NodeJS.WritableStream;
/**
* {@inheritdoc}
*/
protected doWrite(message: string, newline: boolean): void;
/**
* Returns true if the stream supports colorization.
*
* Colorization is disabled if not supported by the stream:
*
* - Windows != 10.0.10586 without Ansicon, ConEmu or Mintty
* - non tty consoles
*
* @return bool true if the stream supports colorization, false otherwise
*/
protected hasColorSupport(): any;
}