本文整理汇总了PHP中PhutilConsole类的典型用法代码示例。如果您正苦于以下问题:PHP PhutilConsole类的具体用法?PHP PhutilConsole怎么用?PHP PhutilConsole使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PhutilConsole类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$ids = $args->getArg('id');
if (!$ids) {
throw new PhutilArgumentUsageException(pht("Use the '%s' flag to specify one or more SMS messages to show.", '--id'));
}
$messages = id(new PhabricatorSMS())->loadAllWhere('id IN (%Ld)', $ids);
if ($ids) {
$ids = array_fuse($ids);
$missing = array_diff_key($ids, $messages);
if ($missing) {
throw new PhutilArgumentUsageException(pht('Some specified SMS messages do not exist: %s', implode(', ', array_keys($missing))));
}
}
$last_key = last_key($messages);
foreach ($messages as $message_key => $message) {
$info = array();
$info[] = pht('PROPERTIES');
$info[] = pht('ID: %d', $message->getID());
$info[] = pht('Status: %s', $message->getSendStatus());
$info[] = pht('To: %s', $message->getToNumber());
$info[] = pht('From: %s', $message->getFromNumber());
$info[] = null;
$info[] = pht('BODY');
$info[] = $message->getBody();
$info[] = null;
$console->writeOut('%s', implode("\n", $info));
if ($message_key != $last_key) {
$console->writeOut("\n%s\n\n", str_repeat('-', 80));
}
}
}
开发者ID:pugong,项目名称:phabricator,代码行数:33,代码来源:PhabricatorSMSManagementShowOutboundWorkflow.php
示例2: execute
public function execute(PhutilArgumentParser $args)
{
$commits = $this->loadCommits($args, 'commits');
if (!$commits) {
throw new PhutilArgumentUsageException('Specify one or more commits to resolve users for.');
}
$console = PhutilConsole::getConsole();
foreach ($commits as $commit) {
$repo = $commit->getRepository();
$name = $repo->formatCommitName($commit->getCommitIdentifier());
$console->writeOut("%s\n", pht('Examining commit %s...', $name));
$ref = id(new DiffusionLowLevelCommitQuery())->setRepository($repo)->withIdentifier($commit->getCommitIdentifier())->execute();
$author = $ref->getAuthor();
$console->writeOut("%s\n", pht('Raw author string: %s', coalesce($author, 'null')));
if ($author !== null) {
$handle = $this->resolveUser($commit, $author);
if ($handle) {
$console->writeOut("%s\n", pht('Phabricator user: %s', $handle->getFullName()));
} else {
$console->writeOut("%s\n", pht('Unable to resolve a corresponding Phabricator user.'));
}
}
$committer = $ref->getCommitter();
$console->writeOut("%s\n", pht('Raw committer string: %s', coalesce($committer, 'null')));
if ($committer !== null) {
$handle = $this->resolveUser($commit, $committer);
if ($handle) {
$console->writeOut("%s\n", pht('Phabricator user: %s', $handle->getFullName()));
} else {
$console->writeOut("%s\n", pht('Unable to resolve a corresponding Phabricator user.'));
}
}
}
return 0;
}
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:PhabricatorRepositoryManagementLookupUsersWorkflow.php
示例3: execute
public function execute(PhutilArgumentParser $args)
{
$can_recover = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withIsAdmin(true)->execute();
if (!$can_recover) {
throw new PhutilArgumentUsageException(pht('This Phabricator installation has no recoverable administrator ' . 'accounts. You can use `bin/accountadmin` to create a new ' . 'administrator account or make an existing user an administrator.'));
}
$can_recover = mpull($can_recover, 'getUsername');
sort($can_recover);
$can_recover = implode(', ', $can_recover);
$usernames = $args->getArg('username');
if (!$usernames) {
throw new PhutilArgumentUsageException(pht('You must specify the username of the account to recover.'));
} else {
if (count($usernames) > 1) {
throw new PhutilArgumentUsageException(pht('You can only recover the username for one account.'));
}
}
$username = head($usernames);
$user = id(new PhabricatorPeopleQuery())->setViewer($this->getViewer())->withUsernames(array($username))->executeOne();
if (!$user) {
throw new PhutilArgumentUsageException(pht('No such user "%s". Recoverable administrator accounts are: %s.', $username, $can_recover));
}
if (!$user->getIsAdmin()) {
throw new PhutilArgumentUsageException(pht('You can only recover administrator accounts, but %s is not an ' . 'administrator. Recoverable administrator accounts are: %s.', $username, $can_recover));
}
$engine = new PhabricatorAuthSessionEngine();
$onetime_uri = $engine->getOneTimeLoginURI($user, null, PhabricatorAuthSessionEngine::ONETIME_RECOVER);
$console = PhutilConsole::getConsole();
$console->writeOut(pht('Use this link to recover access to the "%s" account from the web ' . 'interface:', $username));
$console->writeOut("\n\n");
$console->writeOut(' %s', $onetime_uri);
$console->writeOut("\n\n");
$console->writeOut(pht('After logging in, you can use the "Auth" application to add or ' . 'restore authentication providers and allow normal logins to ' . 'succeed.') . "\n");
return 0;
}
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:PhabricatorAuthManagementRecoverWorkflow.php
示例4: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$resource_type = $args->getArg('type');
if (!$resource_type) {
throw new PhutilArgumentUsageException(pht('Specify a resource type with `%s`.', '--type'));
}
$until = $args->getArg('until');
if (strlen($until)) {
$until = strtotime($until);
if ($until <= 0) {
throw new PhutilArgumentUsageException(pht('Unable to parse argument to "%s".', '--until'));
}
}
$attributes = $args->getArg('attributes');
if ($attributes) {
$options = new PhutilSimpleOptions();
$options->setCaseSensitive(true);
$attributes = $options->parse($attributes);
}
$lease = id(new DrydockLease())->setResourceType($resource_type);
if ($attributes) {
$lease->setAttributes($attributes);
}
if ($until) {
$lease->setUntil($until);
}
$lease->queueForActivation();
echo tsprintf("%s\n", pht('Waiting for daemons to activate lease...'));
$lease->waitUntilActive();
echo tsprintf("%s\n", pht('Activated lease "%s".', $lease->getID()));
return 0;
}
开发者ID:remxcode,项目名称:phabricator,代码行数:33,代码来源:DrydockManagementLeaseWorkflow.php
示例5: execute
public function execute(PhutilArgumentParser $args)
{
$emails = $args->getArg('email');
if (!$emails) {
throw new PhutilArgumentUsageException(pht('You must specify the email to verify.'));
} else {
if (count($emails) > 1) {
throw new PhutilArgumentUsageException(pht('You can only verify one address at a time.'));
}
}
$address = head($emails);
$email = id(new PhabricatorUserEmail())->loadOneWhere('address = %s', $address);
if (!$email) {
throw new PhutilArgumentUsageException(pht('No email exists with address "%s"!', $address));
}
$viewer = $this->getViewer();
$user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withPHIDs(array($email->getUserPHID()))->executeOne();
if (!$user) {
throw new Exception(pht('Email record has invalid user PHID!'));
}
$editor = id(new PhabricatorUserEditor())->setActor($viewer)->verifyEmail($user, $email);
$console = PhutilConsole::getConsole();
$console->writeOut("%s\n", pht('Done.'));
return 0;
}
开发者ID:pugong,项目名称:phabricator,代码行数:25,代码来源:PhabricatorAuthManagementVerifyWorkflow.php
示例6: getConsole
protected function getConsole()
{
if ($this->console) {
return $this->console;
}
return PhutilConsole::getConsole();
}
开发者ID:lsubra,项目名称:libphutil,代码行数:7,代码来源:PhutilConsoleTable.php
示例7: execute
public function execute(PhutilArgumentParser $args)
{
$repos = $this->loadRepositories($args, 'repos');
if (!$repos) {
throw new PhutilArgumentUsageException(pht('Specify one or more repositories to mark imported.'));
}
$new_importing_value = (bool) $args->getArg('mark-not-imported');
$console = PhutilConsole::getConsole();
foreach ($repos as $repo) {
$name = $repo->getDisplayName();
if ($repo->isImporting() && $new_importing_value) {
$console->writeOut("%s\n", pht('Repository "%s" is already importing.', $name));
} else {
if (!$repo->isImporting() && !$new_importing_value) {
$console->writeOut("%s\n", pht('Repository "%s" is already imported.', $name));
} else {
if ($new_importing_value) {
$console->writeOut("%s\n", pht('Marking repository "%s" as importing.', $name));
} else {
$console->writeOut("%s\n", pht('Marking repository "%s" as imported.', $name));
}
$repo->setDetail('importing', $new_importing_value);
$repo->save();
}
}
}
$console->writeOut("%s\n", pht('Done.'));
return 0;
}
开发者ID:truSense,项目名称:phabricator,代码行数:29,代码来源:PhabricatorRepositoryManagementMarkImportedWorkflow.php
示例8: getConsole
private function getConsole()
{
if ($this->console) {
return $this->console;
}
return PhutilConsole::getConsole();
}
开发者ID:lsubra,项目名称:libphutil,代码行数:7,代码来源:PhutilConsoleProgressBar.php
示例9: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$ids = $args->getArg('ids');
if (!$ids) {
throw new PhutilArgumentUsageException('Specify one or more lease IDs to release.');
}
$viewer = $this->getViewer();
$leases = id(new DrydockLeaseQuery())->setViewer($viewer)->withIDs($ids)->execute();
foreach ($ids as $id) {
$lease = idx($leases, $id);
if (!$lease) {
$console->writeErr("Lease %d does not exist!\n", $id);
} else {
if ($lease->getStatus() != DrydockLeaseStatus::STATUS_ACTIVE) {
$console->writeErr("Lease %d is not 'active'!\n", $id);
} else {
$resource = $lease->getResource();
$blueprint = $resource->getBlueprint();
$blueprint->releaseLease($resource, $lease);
$console->writeErr("Released lease %d.\n", $id);
}
}
}
}
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:DrydockManagementReleaseWorkflow.php
示例10: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$iterator = $this->buildIterator($args);
if (!$iterator) {
throw new PhutilArgumentUsageException('Either specify a list of files to purge, or use `--all` ' . 'to purge all files.');
}
$is_dry_run = $args->getArg('dry-run');
foreach ($iterator as $file) {
$fid = 'F' . $file->getID();
try {
$file->loadFileData();
$okay = true;
} catch (Exception $ex) {
$okay = false;
}
if ($okay) {
$console->writeOut("%s: File data is OK, not purging.\n", $fid);
} else {
if ($is_dry_run) {
$console->writeOut("%s: Would purge (dry run).\n", $fid);
} else {
$console->writeOut("%s: Purging.\n", $fid);
$file->delete();
}
}
}
return 0;
}
开发者ID:denghp,项目名称:phabricator,代码行数:29,代码来源:PhabricatorFilesManagementPurgeWorkflow.php
示例11: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$resource_name = $args->getArg('name');
if (!$resource_name) {
throw new PhutilArgumentUsageException('Specify a resource name with `--name`.');
}
$blueprint_id = $args->getArg('blueprint');
if (!$blueprint_id) {
throw new PhutilArgumentUsageException('Specify a blueprint ID with `--blueprint`.');
}
$attributes = $args->getArg('attributes');
if ($attributes) {
$options = new PhutilSimpleOptions();
$options->setCaseSensitive(true);
$attributes = $options->parse($attributes);
}
$viewer = $this->getViewer();
$blueprint = id(new DrydockBlueprintQuery())->setViewer($viewer)->withIDs(array($blueprint_id))->executeOne();
if (!$blueprint) {
throw new PhutilArgumentUsageException('Specified blueprint does not exist.');
}
$resource = id(new DrydockResource())->setBlueprintPHID($blueprint->getPHID())->setType($blueprint->getImplementation()->getType())->setName($resource_name)->setStatus(DrydockResourceStatus::STATUS_OPEN);
if ($attributes) {
$resource->setAttributes($attributes);
}
$resource->save();
$console->writeOut("Created Resource %s\n", $resource->getID());
return 0;
}
开发者ID:denghp,项目名称:phabricator,代码行数:30,代码来源:DrydockManagementCreateResourceWorkflow.php
示例12: log
private function log($pattern)
{
$console = PhutilConsole::getConsole();
$argv = func_get_args();
$argv[0] .= "\n";
call_user_func_array(array($console, 'writeErr'), $argv);
}
开发者ID:bsimser,项目名称:rise-to-power,代码行数:7,代码来源:RtpUnitTestEngine.php
示例13: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$public_keyfile = $args->getArg('public');
if (!strlen($public_keyfile)) {
throw new PhutilArgumentUsageException(pht('You must specify the path to a public keyfile with %s.', '--public'));
}
if (!Filesystem::pathExists($public_keyfile)) {
throw new PhutilArgumentUsageException(pht('Specified public keyfile "%s" does not exist!', $public_keyfile));
}
$public_key = Filesystem::readFile($public_keyfile);
$pkcs8_keyfile = $args->getArg('pkcs8');
if (!strlen($pkcs8_keyfile)) {
throw new PhutilArgumentUsageException(pht('You must specify the path to a pkcs8 keyfile with %s.', '--pkc8s'));
}
if (!Filesystem::pathExists($pkcs8_keyfile)) {
throw new PhutilArgumentUsageException(pht('Specified pkcs8 keyfile "%s" does not exist!', $pkcs8_keyfile));
}
$pkcs8_key = Filesystem::readFile($pkcs8_keyfile);
$warning = pht('Adding a PKCS8 keyfile to the cache can be very dangerous. If the ' . 'PKCS8 file really encodes a different public key than the one ' . 'specified, an attacker could use it to gain unauthorized access.' . "\n\n" . 'Generally, you should use this option only in a development ' . 'environment where ssh-keygen is broken and it is inconvenient to ' . 'fix it, and only if you are certain you understand the risks. You ' . 'should never cache a PKCS8 file you did not generate yourself.');
$console->writeOut("%s\n", phutil_console_wrap($warning));
$prompt = pht('Really trust this PKCS8 keyfile?');
if (!phutil_console_confirm($prompt)) {
throw new PhutilArgumentUsageException(pht('Aborted workflow.'));
}
$key = PhabricatorAuthSSHPublicKey::newFromRawKey($public_key);
$key->forcePopulatePKCS8Cache($pkcs8_key);
$console->writeOut("%s\n", pht('Cached PKCS8 key for public key.'));
return 0;
}
开发者ID:pugong,项目名称:phabricator,代码行数:30,代码来源:PhabricatorAuthManagementCachePKCS8Workflow.php
示例14: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$tasks = $this->loadTasks($args);
foreach ($tasks as $task) {
$can_execute = !$task->isArchived();
if (!$can_execute) {
$console->writeOut("**<bg:yellow> %s </bg>** %s\n", pht('ARCHIVED'), pht('%s is already archived, and can not be executed.', $this->describeTask($task)));
continue;
}
// NOTE: This ignores leases, maybe it should respect them without
// a parameter like --force?
$task->setLeaseOwner(null);
$task->setLeaseExpires(PhabricatorTime::getNow());
$task->save();
$task_data = id(new PhabricatorWorkerTaskData())->loadOneWhere('id = %d', $task->getDataID());
$task->setData($task_data->getData());
$console->writeOut(pht('Executing task %d (%s)...', $task->getID(), $task->getTaskClass()));
$task = $task->executeTask();
$ex = $task->getExecutionException();
if ($ex) {
throw $ex;
}
}
return 0;
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:26,代码来源:PhabricatorWorkerManagementExecuteWorkflow.php
示例15: log
protected function log($message)
{
if ($this->debug) {
$console = PhutilConsole::getConsole();
$console->writeErr("%s\n", $message);
}
}
开发者ID:pugong,项目名称:phabricator,代码行数:7,代码来源:CelerityResourceMapGenerator.php
示例16: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$in = $args->getArg('in');
if (!strlen($in)) {
throw new PhutilArgumentUsageException(pht('Specify the dumpfile to read with --in.'));
}
$from = $args->getArg('from');
if (!strlen($from)) {
throw new PhutilArgumentUsageException(pht('Specify namespace to rename from with --from.'));
}
$to = $args->getArg('to');
if (!strlen($to)) {
throw new PhutilArgumentUsageException(pht('Specify namespace to rename to with --to.'));
}
$patterns = array('use' => '@^(USE `)([^_]+)(_.*)$@', 'create' => '@^(CREATE DATABASE /\\*.*?\\*/ `)([^_]+)(_.*)$@');
$found = array_fill_keys(array_keys($patterns), 0);
$matches = null;
foreach (new LinesOfALargeFile($in) as $line) {
foreach ($patterns as $key => $pattern) {
if (preg_match($pattern, $line, $matches)) {
$namespace = $matches[2];
if ($namespace != $from) {
throw new Exception(pht('Expected namespace "%s", found "%s": %s.', $from, $namespace, $line));
}
$line = $matches[1] . $to . $matches[3];
$found[$key]++;
}
}
echo $line . "\n";
}
// Give the user a chance to catch things if the results are crazy.
$console->writeErr(pht('Adjusted **%s** create statements and **%s** use statements.', new PhutilNumber($found['create']), new PhutilNumber($found['use'])) . "\n");
return 0;
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:35,代码来源:PhabricatorStorageManagementRenamespaceWorkflow.php
示例17: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$daemon = new PhabricatorFactDaemon(array());
$daemon->setVerbose(true);
$daemon->setEngines(PhabricatorFactEngine::loadAllEngines());
$iterators = PhabricatorFactDaemon::getAllApplicationIterators();
$selected = $args->getArg('iterator');
if ($selected) {
$use = array();
foreach ($selected as $iterator_name) {
if (isset($iterators[$iterator_name])) {
$use[$iterator_name] = $iterators[$iterator_name];
} else {
$console->writeErr("%s\n", pht("Iterator '%s' does not exist.", $iterator_name));
}
}
$iterators = $use;
}
foreach ($iterators as $iterator_name => $iterator) {
if ($args->getArg('all')) {
$daemon->processIterator($iterator);
} else {
$daemon->processIteratorWithCursor($iterator_name, $iterator);
}
}
if (!$args->getArg('skip-aggregates')) {
$daemon->processAggregates();
}
return 0;
}
开发者ID:nexeck,项目名称:phabricator,代码行数:31,代码来源:PhabricatorFactManagementAnalyzeWorkflow.php
示例18: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$purge_all = $args->getArg('purge-all');
$purge = array('remarkup' => $purge_all || $args->getArg('purge-remarkup'), 'changeset' => $purge_all || $args->getArg('purge-changeset'), 'general' => $purge_all || $args->getArg('purge-general'));
if (!array_filter($purge)) {
$list = array();
foreach ($purge as $key => $ignored) {
$list[] = "'--purge-" . $key . "'";
}
throw new PhutilArgumentUsageException("Specify which cache or caches to purge, or use '--purge-all'. " . "Available caches are: " . implode(', ', $list) . ". Use '--help' " . "for more information.");
}
if ($purge['remarkup']) {
$console->writeOut('Purging remarkup cache...');
$this->purgeRemarkupCache();
$console->writeOut("done.\n");
}
if ($purge['changeset']) {
$console->writeOut('Purging changeset cache...');
$this->purgeChangesetCache();
$console->writeOut("done.\n");
}
if ($purge['general']) {
$console->writeOut('Purging general cache...');
$this->purgeGeneralCache();
$console->writeOut("done.\n");
}
}
开发者ID:denghp,项目名称:phabricator,代码行数:28,代码来源:PhabricatorCacheManagementPurgeWorkflow.php
示例19: execute
public function execute(PhutilArgumentParser $args)
{
$console = PhutilConsole::getConsole();
$argv = $args->getArg('args');
if (count($argv) == 0) {
throw new PhutilArgumentUsageException('Specify a configuration key to get.');
}
$key = $argv[0];
if (count($argv) > 1) {
throw new PhutilArgumentUsageException('Too many arguments: expected one key.');
}
$options = PhabricatorApplicationConfigOptions::loadAllOptions();
if (empty($options[$key])) {
throw new PhutilArgumentUsageException("No such configuration key '{$key}'! Use `config list` to list all " . "keys.");
}
$config = new PhabricatorConfigLocalSource();
$values = $config->getKeys(array($key));
$result = array();
foreach ($values as $key => $value) {
$result[] = array('key' => $key, 'source' => 'local', 'value' => $value);
}
$result = array('config' => $result);
$json = new PhutilJSON();
$console->writeOut($json->encodeFormatted($result));
}
开发者ID:denghp,项目名称:phabricator,代码行数:25,代码来源:PhabricatorConfigManagementGetWorkflow.php
示例20: execute
public function execute(PhutilArgumentParser $args)
{
$saw_any_rows = false;
$console = PhutilConsole::getConsole();
$table = new DifferentialLegacyHunk();
foreach (new LiskMigrationIterator($table) as $hunk) {
$saw_any_rows = true;
$id = $hunk->getID();
$console->writeOut("%s\n", pht('Migrating hunk %d...', $id));
$new_hunk = id(new DifferentialModernHunk())->setChangesetID($hunk->getChangesetID())->setOldOffset($hunk->getOldOffset())->setOldLen($hunk->getOldLen())->setNewOffset($hunk->getNewOffset())->setNewLen($hunk->getNewLen())->setChanges($hunk->getChanges())->setDateCreated($hunk->getDateCreated())->setDateModified($hunk->getDateModified());
$hunk->openTransaction();
$new_hunk->save();
$hunk->delete();
$hunk->saveTransaction();
$old_len = strlen($hunk->getChanges());
$new_len = strlen($new_hunk->getData());
if ($old_len) {
$diff_len = $old_len - $new_len;
$console->writeOut("%s\n", pht('Saved %s bytes (%s).', new PhutilNumber($diff_len), sprintf('%.1f%%', 100 * ($diff_len / $old_len))));
}
}
if ($saw_any_rows) {
$console->writeOut("%s\n", pht('Done.'));
} else {
$console->writeOut("%s\n", pht('No rows to migrate.'));
}
}
开发者ID:pugong,项目名称:phabricator,代码行数:27,代码来源:PhabricatorHunksManagementMigrateWorkflow.php
注:本文中的PhutilConsole类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论