Page MenuHomePhorge
Diviner Arcanist Tech Docs PhutilConsoleProgressBar

final class PhutilConsoleProgressBar
Arcanist Technical Documentation ()

Show a progress bar on the console. Usage:

// Create a progress bar, and configure the total amount of work that
// needs to be done.
$bar = id(new PhutilConsoleProgressBar())
  ->setTotal(count($stuff));

// As you complete the work, update the progress bar.
foreach ($stuff as $thing) {
  do_stuff($thing);
  $bar->update(1);
}

// When complete, mark the work done to clear the bar.
$bar->done();

The progress bar attempts to account for various special cases, notably:

  • If stderr is not a TTY, the bar will not be drawn (for example, if it is being piped to a log file).
  • If the Phutil log output is enabled (usually because --trace was specified), the bar will not be drawn.
  • The bar will be resized to the width of the console if possible.

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.

public function setConsole($console)

This method is not documented.
Parameters
PhutilConsole$console
Return
wild

private function getConsole()

This method is not documented.
Return
wild

public function setTotal($work)

This method is not documented.
Parameters
$work
Return
wild

public function setQuiet($quiet)

This method is not documented.
Parameters
$quiet
Return
wild

public function update($work)

This method is not documented.
Parameters
$work
Return
wild

private function redraw()

This method is not documented.
Return
wild

public function draw()

Explicitly redraw the bar.

Normally, the progress bar is automatically redrawn periodically, but you may want to force it to draw.

For example, we force a draw after pre-filling the bar when resuming large file uploads in arc upload. Otherwise, the bar may sit at 0% until the first chunk completes.

Return
wild

public function done($clean_exit)

This method is not documented.
Parameters
$clean_exit
Return
wild

private function eraseLine()

This method is not documented.
Return
wild

private function getWidth()

This method is not documented.
Return
wild

public function __destruct()

This method is not documented.
Return
wild