/** * Instantiates object, sets cache and session * * @return [TerminusCommand] $this */ public function __construct() { //Load commonly used data from cache $this->cache = Terminus::getCache(); $this->logger = Terminus::getLogger(); $this->outputter = Terminus::getOutputter(); $this->session = Session::instance(); if (!Terminus::isTest()) { $this->checkForUpdate(); } }
public function testIsTest() { $this->assertTrue(Terminus::isTest()); }
/** * Launch another Terminus command using the runtime arguments for the * current process * * @param string $command Command to call * @param array $args Positional arguments to use * @param array $assoc_args Associative arguments to use * @param bool $exit_on_error True to exit if the command returns error * @return int The command exit status */ public static function launchSelf($command, $args = array(), $assoc_args = array(), $exit_on_error = true) { $reused_runtime_args = array('path', 'url', 'user', 'allow-root'); foreach ($reused_runtime_args as $key) { if (array_key_exists($key, self::getRunner()->config)) { $assoc_args[$key] = self::getRunner()->config[$key]; } } if (Terminus::isTest()) { $script_path = __DIR__ . '/boot-fs.php'; } else { $script_path = $GLOBALS['argv'][0]; } $php_bin = '"' . self::getPhpBinary() . '"'; $script_path = '"' . $script_path . '"'; $escaped_args = array_map('escapeshellarg', $args); $args = implode(' ', $escaped_args); $assoc_args = Utils\assocArgsToStr($assoc_args); $full_command = "{$php_bin} {$script_path} {$command} {$args} {$assoc_args}"; $status = self::launch($full_command, $exit_on_error); return $status; }