当前位置: 首页>>代码示例>>PHP>>正文


PHP PhutilConsole类代码示例

本文整理汇总了PHP中PhutilConsole的典型用法代码示例。如果您正苦于以下问题:PHP PhutilConsole类的具体用法?PHP PhutilConsole怎么用?PHP PhutilConsole使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PhutilConsole类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的PhutilConsole类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。