Page MenuHomePhorge

final class PhutilConsole
Arcanist Technical Documentation ()

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

public function __get($name)
Inherited

This method is not documented.
Parameters
$name
Return
wild

public function __set($name, $value)
Inherited

This method is not documented.
Parameters
$name
$value
Return
wild

public function current()
Inherited

This method is not documented.
Return
wild

public function key()
Inherited

This method is not documented.
Return
wild

public function next()
Inherited

This method is not documented.
Return
wild

public function rewind()
Inherited

This method is not documented.
Return
wild

public function valid()
Inherited

This method is not documented.
Return
wild

private function throwOnAttemptedIteration()
Inherited

This method is not documented.
Return
wild

public function getPhobjectClassConstant($key, $byte_limit)
Inherited

Phobject

Read the value of a class constant.

This is the same as just typing self::CONSTANTNAME, but throws a more useful message if the constant is not defined and allows the constant to be limited to a maximum length.

Parameters
string$keyName of the constant.
int|null$byte_limitMaximum number of bytes permitted in the value.
Return
stringValue of the constant.

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