本文整理汇总了PHP中Terminus::line方法的典型用法代码示例。如果您正苦于以下问题:PHP Terminus::line方法的具体用法?PHP Terminus::line怎么用?PHP Terminus::line使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus
的用法示例。
在下文中一共展示了Terminus::line方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _url
protected function _url($args, $callback)
{
foreach ($args as $obj_id) {
$object = $this->fetcher->get_check($obj_id);
\Terminus::line($callback($object->{$this->obj_id_key}));
}
}
示例2: prompt
private function prompt($question, $default)
{
try {
$response = \cli\prompt($question, $default);
} catch (\Exception $e) {
\Terminus::line();
return false;
}
return $response;
}
示例3: show_usage
function show_usage()
{
$methods = $this->get_subcommands();
$i = 0;
foreach ($methods as $name => $subcommand) {
$prefix = 0 == $i++ ? 'usage: ' : ' or: ';
\Terminus::line($subcommand->get_usage($prefix));
}
\Terminus::line();
\Terminus::line("See 'terminus help {$this->name} <command>' for more information on a specific command.");
}
示例4: _checkSession
private function _checkSession()
{
if (!property_exists($this, "session") || !property_exists($this->session, "user_uuid")) {
return false;
}
$results = $this->terminus_request("user", $this->session->user_uuid, "profile", "GET");
if ($results['info']['http_code'] >= 400) {
Terminus::line("Expired Session, please re-authenticate.");
$this->cache->remove('session');
Terminus::launch_self("auth", array("login"));
$this->whoami();
return true;
} else {
return $results['info']['http_code'] <= 199 || $results['info']['http_code'] >= 300 ? false : true;
}
}
示例5: info
/**
* Print various data about the CLI environment.
*
* ## OPTIONS
*
* [--format=<format>]
* : Accepted values: json
*/
function info($_, $assoc_args)
{
$php_bin = defined('PHP_BINARY') ? PHP_BINARY : getenv('TERMINUS_PHP_USED');
$runner = Terminus::get_runner();
if (isset($assoc_args['format']) && 'json' === $assoc_args['format']) {
$info = array('php_binary_path' => $php_bin, 'global_config_path' => $runner->global_config_path, 'project_config_path' => $runner->project_config_path, 'wp_cli_dir_path' => TERMINUS_ROOT, 'wp_cli_version' => TERMINUS_VERSION);
Terminus::line(json_encode($info));
} else {
Terminus::line("PHP binary:\t" . $php_bin);
Terminus::line("PHP version:\t" . PHP_VERSION);
Terminus::line("php.ini used:\t" . get_cfg_var('cfg_file_path'));
Terminus::line("Terminus root dir:\t" . TERMINUS_ROOT);
Terminus::line("Terminus global config:\t" . $runner->global_config_path);
Terminus::line("Terminus project config:\t" . $runner->project_config_path);
Terminus::line("Terminus version:\t" . TERMINUS_VERSION);
}
}
示例6: feedback
function feedback($string)
{
if (isset($this->upgrader->strings[$string])) {
$string = $this->upgrader->strings[$string];
}
if (strpos($string, '%') !== false) {
$args = func_get_args();
$args = array_splice($args, 1);
if (!empty($args)) {
$string = vsprintf($string, $args);
}
}
if (empty($string)) {
return;
}
$string = str_replace('…', '...', strip_tags($string));
\Terminus::line($string);
}
示例7: wait
/**
* Waits on this workflow to finish
*
* @return [Workflow] $this
*/
public function wait()
{
while (!$this->isFinished()) {
$this->fetch();
sleep(3);
// TODO: output this to stdout so that it doesn't get mixed with any actual output.
// We can't use the logger here because that might be redirected to a log-file and each line is timestamped.
\Terminus::out(".");
}
// TODO: output this to stdout so that it doesn't get mixed with any actual output.
\Terminus::line();
if ($this->isSuccessful()) {
return $this;
} else {
$final_task = $this->get('final_task');
if ($final_task != null && !empty($final_task->messages)) {
foreach ($final_task->messages as $data => $message) {
throw new TerminusException($message->message);
}
}
}
}
示例8: __invoke
/**
* Invoke `wp` commands on a Pantheon development site
*
* <commands>...
* : The WP-CLI commands you intend to run.
*
* [--<flag>=<value>]
* : Additional WP-CLI flag(s) to pass in to the command.
*
* --site=<site>
* : The name (DNS shortname) of your site on Pantheon.
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
function __invoke($args, $assoc_args)
{
$site_name = $assoc_args['site'];
if (isset($assoc_args['env'])) {
$environment = $assoc_args['env'];
} else {
$environment = 'dev';
}
$site = SiteFactory::instance($site_name);
if (!$site) {
Terminus::error("Command could not be completed.");
exit;
}
# see https://github.com/pantheon-systems/titan-mt/blob/master/dashboardng/app/workshops/site/models/environment.coffee
$server = array('user' => "{$environment}.{$site->getId()}", 'host' => "appserver.{$environment}.{$site->getId()}.drush.in", 'port' => '2222');
if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
$server['user'] = "appserver.{$environment}.{$site->getId()}";
$server['host'] = TERMINUS_HOST;
}
# Sanitize assoc args so we don't try to pass our own flags.
# TODO: DRY this out?
unset($assoc_args['site']);
if (isset($assoc_args['env'])) {
unset($assoc_args['env']);
}
# Create user-friendly output
$command = implode($args, ' ');
$flags = '';
foreach ($assoc_args as $k => $v) {
if (isset($v) && (string) $v != '') {
$flags .= "--{$k}=" . escapeshellarg($v) . ' ';
} else {
$flags .= "--{$k} ";
}
}
Terminus::line("Running wp %s %s on %s-%s", array($command, $flags, $site->getName(), $environment));
$this->send_command($server, 'wp', $args, $assoc_args);
}
示例9: __invoke
/**
* Invoke `drush` commands on a Pantheon development site
*
* <commands>...
* : The Drush commands you intend to run.
*
* [--<flag>=<value>]
* : Additional Drush flag(s) to pass in to the command.
*
* --site=<site>
* : The name (DNS shortname) of your site on Pantheon.
*
* [--env=<environment>]
* : Your Pantheon environment. Default: dev
*
*/
function __invoke($args, $assoc_args)
{
$site_name = $assoc_args['site'];
if (isset($assoc_args['env'])) {
$environment = $assoc_args['env'];
} else {
$environment = 'dev';
}
$site = SiteFactory::instance($site_name);
if (!$site) {
Terminus::error("Command could not be completed.");
exit;
}
$server = array('user' => "{$environment}.{$site->getId()}", 'host' => "appserver.{$environment}.{$site->getId()}.drush.in", 'port' => '2222');
if (strpos(TERMINUS_HOST, 'onebox') !== FALSE) {
$server['user'] = "appserver.{$environment}.{$site->getId()}";
$server['host'] = TERMINUS_HOST;
}
# Sanitize assoc args so we don't try to pass our own flags.
# TODO: DRY this out?
unset($assoc_args['site']);
if (isset($assoc_args['env'])) {
unset($assoc_args['env']);
}
# Create user-friendly output
$command = implode($args, ' ');
$flags = '';
foreach ($assoc_args as $k => $v) {
if (isset($v) && (string) $v != '') {
$flags .= "--{$k}={$v} ";
} else {
$flags .= "--{$k} ";
}
}
Terminus::line("Running drush %s %s on %s-%s", array($command, $flags, $site->getName(), $environment));
$this->send_command($server, 'drush', $args, $assoc_args);
}
示例10: redis
/**
* Interacts with redis
*
* ## OPTIONS
*
* <clear>
* : clear - Clear redis cache on remote server
*
* [--site=<site>]
* : site name
*
* [--env=<env>]
* : environment
*
* ## Examples
*
* terminus site redis clear --site=mikes-wp-test --env=live
*
*/
public function redis($args, $assoc_args)
{
$action = array_shift($args);
$site = SiteFactory::instance(Input::sitename($assoc_args));
$env = @$assoc_args['env'];
switch ($action) {
case 'clear':
$bindings = $site->bindings('cacheserver');
if (empty($bindings)) {
\Terminus::error("Redis cache not enabled");
}
$commands = array();
foreach ($bindings as $binding) {
if (@$env and $env != $binding->environment) {
continue;
}
// @$todo ... should probably do this with symfony Process lib
$args = array($binding->environment, $site->getId(), $binding->environment, $site->getId(), $binding->host, $binding->port, $binding->password);
array_filter($args, function ($a) {
return escapeshellarg($a);
});
$commands[$binding->environment] = vsprintf('ssh -p 2222 %s.%s@appserver.%s.%s.drush.in "redis-cli -h %s -p %s -a %s flushall"', $args);
}
foreach ($commands as $env => $command) {
Terminus::line("Clearing redis on %s ", array($env));
exec($command, $stdout, $return);
echo Logger::greenLine($stdout[0]);
}
break;
}
}
示例11: render
public function render()
{
foreach ($this->opts as $opt) {
\Terminus::line($opt);
}
}
示例12: upstream_updates
/**
* Show or apply upstream updates
*
* ## OPTIONS
*
* [--site=<site>]
* : Site to check
*
* [--update]
* : Apply upstream updates
*
* [--env=<name>]
* : Environment (dev or multidev) to apply updates to; Default: dev
*
* [--updatedb]
* : (Drupal only) run update.php after deploy
*
* @alias upstream-updates
**/
public function upstream_updates($args, $assoc_args)
{
$site = $this->sites->get(Input::sitename($assoc_args));
$upstream = $site->getUpstreamUpdates();
$data = array();
if (isset($upstream->remote_url) && isset($upstream->behind)) {
$data[$upstream->remote_url] = 'Up-to-date';
if ($upstream->behind > 0) {
$data[$upstream->remote_url] = 'Updates Available';
}
$this->constructTableForResponse($data, array('Upstream', 'Status'));
if (!isset($upstream) || empty($upstream->update_log)) {
Terminus::success('No updates to show');
}
$upstreams = (array) $upstream->update_log;
if (!empty($upstreams)) {
$data = array();
foreach ($upstreams as $commit) {
$data[] = array('hash' => $commit->hash, 'datetime' => $commit->datetime, 'message' => $commit->message, 'author' => $commit->author);
}
$this->outputter->outputRecordList($data);
}
} else {
Terminus::line('There was a problem checking your upstream status. Please try again.');
}
if (isset($assoc_args['update']) && !empty($upstream->update_log)) {
$env = 'dev';
if (isset($assoc_args['env'])) {
$env = $assoc_args['env'];
}
if (in_array($env, array('test', 'live'))) {
Terminus::error(sprintf('Upstream updates cannot be applied to the %s environment', $env));
}
$updatedb = isset($assoc_args['updatedb']) && $assoc_args['updatedb'];
Terminus::confirm(sprintf('Are you sure you want to apply the upstream updates to %s-dev', $site->get('name'), $env));
$workflow = $site->applyUpstreamUpdates($env, $updatedb);
$workflow->wait();
$this->workflowOutput($workflow);
}
}
示例13: delete
/**
* Delete a site from pantheon
*
* ## OPTIONS
* --site=<site>
* : Id of the site you want to delete
*
* [--all]
* : Just kidding ... we won't let you do that.
*
* [--force]
* : to skip the confirmations
*
*/
function delete($args, $assoc_args)
{
$site_to_delete = SiteFactory::instance(@$assoc_args['site']);
if (!$site_to_delete) {
foreach (SiteFactory::instance() as $id => $site) {
$site->id = $id;
$sites[] = $site;
$menu[] = $site->information->name;
}
$index = Terminus::menu($menu, null, "Select a site to delete");
$site_to_delete = $sites[$index];
}
if (!isset($assoc_args['force']) and !Terminus::get_config('yes')) {
// if the force option isn't used we'll ask you some annoying questions
Terminus::confirm(sprintf("Are you sure you want to delete %s?", $site_to_delete->information->name));
Terminus::confirm("Are you really sure?");
}
Terminus::line(sprintf("Deleting %s ...", $site_to_delete->information->name));
$response = \Terminus_Command::request('sites', $site_to_delete->id, '', 'DELETE');
Terminus::success("Deleted %s!", $site_to_delete->information->name);
}
示例14: _debug
protected function _debug($vars)
{
Terminus::line(print_r($this, true));
Terminus::line(print_r($vars, true));
}
示例15: promptSecret
/**
* Prompt the user for input
*
* @param string $message
*/
static function promptSecret($message = '', $params = array(), $default = null)
{
exec("stty -echo");
$response = Terminus::prompt($message, $params);
exec("stty echo");
Terminus::line();
return $response;
}