Page MenuHomePhabricator

final class PhutilConsole
libphutil Technical Documentation (Console)

Provides access to the command-line console. Instead of reading from or writing to stdin/stdout/stderr directly, this class provides a richer API including support for ANSI color and formatting, convenience methods for prompting the user, and the ability to interact with stdin/stdout/stderr in some other process instead of this one.

Tasks

Construction

  • private function __construct() — Use @{method:newLocalConsole} or @{method:newRemoteConsole} to construct new consoles.
  • public static function getConsole() — Get the current console. If there's no active console, a new local console is created (see @{method:newLocalConsole} for details). You can change the active console with @{method:setConsole}.
  • public static function setConsole($console) — Set the active console.
  • public static function newLocalConsole() — Create a new console attached to stdin/stdout/stderr of this process. This is how consoles normally work -- for instance, writing output with @{method:writeOut} prints directly to stdout. If you don't create a console explicitly, a new local console is created for you.

Interfacing with the User

No methods for this task.

Internals

No methods for this task.

Other Methods

Methods

private function __construct()

Use newLocalConsole() or newRemoteConsole() to construct new consoles.

Return
this//Implicit.//

public static function getConsole()

Get the current console. If there's no active console, a new local console is created (see newLocalConsole() for details). You can change the active console with setConsole().

Return
PhutilConsoleActive console.

public static function setConsole($console)

Set the active console.

Parameters
PhutilConsole$console
Return
void

public static function newLocalConsole()

Create a new console attached to stdin/stdout/stderr of this process. This is how consoles normally work -- for instance, writing output with writeOut() prints directly to stdout. If you don't create a console explicitly, a new local console is created for you.

Return
PhutilConsoleA new console which operates on the pipes of this process.

public static function newConsoleForServer($server)

This method is not documented.
Parameters
PhutilConsoleServer$server
Return
wild

public static function newRemoteConsole()

This method is not documented.
Return
wild

public function confirm($prompt, $default)

This method is not documented.
Parameters
$prompt
$default
Return
wild

public function prompt($prompt, $history)

This method is not documented.
Parameters
$prompt
$history
Return
wild

public function sendMessage($data)

This method is not documented.
Parameters
$data
Return
wild

public function writeOut($pattern)

This method is not documented.
Parameters
$pattern
Return
wild

public function writeErr($pattern)

This method is not documented.
Parameters
$pattern
Return
wild

public function writeLog($pattern)

This method is not documented.
Parameters
$pattern
Return
wild

public function beginRedirectOut()

This method is not documented.
Return
wild

public function endRedirectOut()

This method is not documented.
Return
wild

public function redirectOutCallback($string)

This method is not documented.
Parameters
$string
Return
wild

private function writeTextMessage($type, $argv)

This method is not documented.
Parameters
$type
array$argv
Return
wild

private function writeMessage($message)

This method is not documented.
Parameters
PhutilConsoleMessage$message
Return
wild

private function waitForMessage()

This method is not documented.
Return
wild

public function getServer()

This method is not documented.
Return
wild

private function disableMessageType($type)

This method is not documented.
Parameters
$type
Return
wild

private function enableMessageType($type)

This method is not documented.
Parameters
$type
Return
wild

public function disableOut()

This method is not documented.
Return
wild

public function enableOut()

This method is not documented.
Return
wild

public function isLogEnabled()

This method is not documented.
Return
wild

public function isErrATTY()

This method is not documented.
Return
wild

public function getErrCols()

This method is not documented.
Return
wild