Changeset View
Changeset View
Standalone View
Standalone View
src/toolset/command/ArcanistCommand.php
<?php | <?php | ||||
final class ArcanistCommand | final class ArcanistCommand | ||||
extends Phobject { | extends Phobject { | ||||
private $logEngine; | private $logEngine; | ||||
private $executableFuture; | private $executableFuture; | ||||
private $resolveOnError = false; | private $resolveOnError = false; | ||||
private $displayCommand; | |||||
public function setExecutableFuture(PhutilExecutableFuture $future) { | public function setExecutableFuture(PhutilExecutableFuture $future) { | ||||
$this->executableFuture = $future; | $this->executableFuture = $future; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getExecutableFuture() { | public function getExecutableFuture() { | ||||
return $this->executableFuture; | return $this->executableFuture; | ||||
Show All 12 Lines | public function setResolveOnError($resolve_on_error) { | ||||
$this->resolveOnError = $resolve_on_error; | $this->resolveOnError = $resolve_on_error; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getResolveOnError() { | public function getResolveOnError() { | ||||
return $this->resolveOnError; | return $this->resolveOnError; | ||||
} | } | ||||
public function setDisplayCommand($pattern /* , ... */) { | |||||
$argv = func_get_args(); | |||||
$command = call_user_func_array('csprintf', $argv); | |||||
$this->displayCommand = $command; | |||||
return $this; | |||||
} | |||||
public function getDisplayCommand() { | |||||
return $this->displayCommand; | |||||
} | |||||
public function execute() { | public function execute() { | ||||
$log = $this->getLogEngine(); | $log = $this->getLogEngine(); | ||||
$future = $this->getExecutableFuture(); | $future = $this->getExecutableFuture(); | ||||
$display_command = $this->getDisplayCommand(); | |||||
if ($display_command !== null) { | |||||
$command = $display_command; | |||||
} else { | |||||
$command = $future->getCommand(); | $command = $future->getCommand(); | ||||
} | |||||
$log->writeNewline(); | $log->writeNewline(); | ||||
$log->writeStatus( | $log->writeStatus( | ||||
' $ ', | ' $ ', | ||||
tsprintf('**%s**', phutil_string_cast($command))); | tsprintf('**%s**', phutil_string_cast($command))); | ||||
$log->writeNewline(); | $log->writeNewline(); | ||||
Show All 23 Lines |