• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP PhutilArgumentParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了PhutilArgumentParser类的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: loadTasks

 protected function loadTasks(PhutilArgumentParser $args)
 {
     $ids = $args->getArg('id');
     $class = $args->getArg('class');
     $min_failures = $args->getArg('min-failure-count');
     if (!$ids && !$class && !$min_failures) {
         throw new PhutilArgumentUsageException(pht('Use --id, --class, or --min-failure-count to select tasks.'));
     }
     $active_query = new PhabricatorWorkerActiveTaskQuery();
     $archive_query = new PhabricatorWorkerArchiveTaskQuery();
     if ($ids) {
         $active_query = $active_query->withIDs($ids);
         $archive_query = $archive_query->withIDs($ids);
     }
     if ($class) {
         $class_array = array($class);
         $active_query = $active_query->withClassNames($class_array);
         $archive_query = $archive_query->withClassNames($class_array);
     }
     if ($min_failures) {
         $active_query = $active_query->withFailureCountBetween($min_failures, null);
         $archive_query = $archive_query->withFailureCountBetween($min_failures, null);
     }
     $active_tasks = $active_query->execute();
     $archive_tasks = $archive_query->execute();
     $tasks = mpull($active_tasks, null, 'getID') + mpull($archive_tasks, null, 'getID');
     if ($ids) {
         foreach ($ids as $id) {
             if (empty($tasks[$id])) {
                 throw new PhutilArgumentUsageException(pht('No task exists with id "%s"!', $id));
             }
         }
     }
     if ($class && $min_failures) {
         if (!$tasks) {
             throw new PhutilArgumentUsageException(pht('No task exists with class "%s" and at least %d failures!', $class, $min_failures));
         }
     } else {
         if ($class) {
             if (!$tasks) {
                 throw new PhutilArgumentUsageException(pht('No task exists with class "%s"!', $class));
             }
         } else {
             if ($min_failures) {
                 if (!$tasks) {
                     throw new PhutilArgumentUsageException(pht('No tasks exist with at least %d failures!', $min_failures));
                 }
             }
         }
     }
     // When we lock tasks properly, this gets populated as a side effect. Just
     // fake it when doing manual CLI stuff. This makes sure CLI yields have
     // their expires times set properly.
     foreach ($tasks as $task) {
         if ($task instanceof PhabricatorWorkerActiveTask) {
             $task->setServerTime(PhabricatorTime::getNow());
         }
     }
     return $tasks;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:60,代码来源:PhabricatorWorkerManagementWorkflow.php


示例3: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $paths = $args->getArg('paths');
     if (!$paths) {
         $paths = array(getcwd());
     }
     $targets = array();
     foreach ($paths as $path) {
         $root = Filesystem::resolvePath($path);
         if (!Filesystem::pathExists($root) || !is_dir($root)) {
             throw new PhutilArgumentUsageException(pht('Path "%s" does not exist, or is not a directory.', $path));
         }
         $libraries = id(new FileFinder($path))->withPath('*/__phutil_library_init__.php')->find();
         if (!$libraries) {
             throw new PhutilArgumentUsageException(pht('Path "%s" contains no libphutil libraries.', $path));
         }
         foreach ($libraries as $library) {
             $targets[] = Filesystem::resolvePath(dirname($library)) . '/';
         }
     }
     $targets = array_unique($targets);
     foreach ($targets as $library) {
         echo tsprintf("**<bg:blue> %s </bg>** %s\n", pht('EXTRACT'), pht('Extracting "%s"...', Filesystem::readablePath($library)));
         $this->extractLibrary($library);
     }
     return 0;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:28,代码来源:PhabricatorInternationalizationManagementExtractWorkflow.php


示例4: execute

 public function execute(PhutilArgumentParser $args)
 {
     $is_dry = $args->getArg('dryrun');
     $is_force = $args->getArg('force');
     if (!$is_dry && !$is_force) {
         echo phutil_console_wrap("Are you completely sure you really want to permanently destroy all " . "storage for Phabricator data? This operation can not be undone and " . "your data will not be recoverable if you proceed.");
         if (!phutil_console_confirm('Permanently destroy all data?')) {
             echo "Cancelled.\n";
             exit(1);
         }
         if (!phutil_console_confirm('Really destroy all data forever?')) {
             echo "Cancelled.\n";
             exit(1);
         }
     }
     $api = $this->getAPI();
     $patches = $this->getPatches();
     $databases = $api->getDatabaseList($patches);
     $databases[] = $api->getDatabaseName('meta_data');
     foreach ($databases as $database) {
         if ($is_dry) {
             echo "DRYRUN: Would drop database '{$database}'.\n";
         } else {
             echo "Dropping database '{$database}'...\n";
             queryfx($api->getConn('meta_data', $select_database = false), 'DROP DATABASE IF EXISTS %T', $database);
         }
     }
     if (!$is_dry) {
         echo "Storage was destroyed.\n";
     }
     return 0;
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:32,代码来源:PhabricatorStorageManagementDestroyWorkflow.php


示例5: didExecute

 public function didExecute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $patches = $this->getPatches();
     if (!$this->isDryRun() && !$this->isForce()) {
         $console->writeOut(phutil_console_wrap(pht('Before running storage upgrades, you should take down the ' . 'Phabricator web interface and stop any running Phabricator ' . 'daemons (you can disable this warning with %s).', '--force')));
         if (!phutil_console_confirm(pht('Are you ready to continue?'))) {
             $console->writeOut("%s\n", pht('Cancelled.'));
             return 1;
         }
     }
     $apply_only = $args->getArg('apply');
     if ($apply_only) {
         if (empty($patches[$apply_only])) {
             throw new PhutilArgumentUsageException(pht("%s argument '%s' is not a valid patch. " . "Use '%s' to show patch status.", '--apply', $apply_only, './bin/storage status'));
         }
     }
     $no_quickstart = $args->getArg('no-quickstart');
     $init_only = $args->getArg('init-only');
     $no_adjust = $args->getArg('no-adjust');
     $this->upgradeSchemata($apply_only, $no_quickstart, $init_only);
     if ($no_adjust || $init_only || $apply_only) {
         $console->writeOut("%s\n", pht('Declining to apply storage adjustments.'));
         return 0;
     } else {
         return $this->adjustSchemata(false);
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:28,代码来源:PhabricatorStorageManagementUpgradeWorkflow.php


示例6: loadITem

 protected function loadITem(PhutilArgumentParser $argv, $key)
 {
     $item = $argv->getArg($key);
     if (!strlen($item)) {
         throw new PhutilArgumentUsageException(pht('Specify a item with %s.', '--' . $key));
     }
     $query = id(new NuanceItemQuery())->setViewer($this->getViewer())->setRaisePolicyExceptions(true);
     $type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN;
     if (ctype_digit($item)) {
         $kind = 'id';
         $query->withIDs(array($item));
     } else {
         if (phid_get_type($item) !== $type_unknown) {
             $kind = 'phid';
             $query->withPHIDs($item);
         } else {
             throw new PhutilArgumentUsageException(pht('Specify the ID or PHID of an item to update. Parameter "%s" ' . 'is not an ID or PHID.', $item));
         }
     }
     $items = $query->execute();
     if (!$items) {
         switch ($kind) {
             case 'id':
                 $message = pht('No item exists with ID "%s".', $item);
                 break;
             case 'phid':
                 $message = pht('No item exists with PHID "%s".', $item);
                 break;
         }
         throw new PhutilArgumentUsageException($message);
     }
     return head($items);
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:33,代码来源:NuanceManagementWorkflow.php


示例7: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $reset = $args->getArg('reset');
     if ($reset) {
         foreach ($reset as $name) {
             $cursor = id(new PhabricatorFactCursor())->loadOneWhere('name = %s', $name);
             if ($cursor) {
                 $console->writeOut("%s\n", pht("Resetting cursor %s...", $name));
                 $cursor->delete();
             } else {
                 $console->writeErr("%s\n", pht("Cursor %s does not exist or is already reset.", $name));
             }
         }
         return 0;
     }
     $iterator_map = PhabricatorFactDaemon::getAllApplicationIterators();
     if (!$iterator_map) {
         $console->writeErr("%s\n", pht("No cursors."));
         return 0;
     }
     $cursors = id(new PhabricatorFactCursor())->loadAllWhere('name IN (%Ls)', array_keys($iterator_map));
     $cursors = mpull($cursors, 'getPosition', 'getName');
     foreach ($iterator_map as $iterator_name => $iterator) {
         $console->writeOut("%s (%s)\n", $iterator_name, idx($cursors, $iterator_name, 'start'));
     }
     return 0;
 }
开发者ID:nexeck,项目名称:phabricator,代码行数:28,代码来源:PhabricatorFactManagementCursorsWorkflow.php


示例8: execute

 public function execute(PhutilArgumentParser $args)
 {
     $supported_types = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorTestDataGenerator')->loadObjects();
     echo "These are the types of data you can generate:\n";
     foreach (array_keys($supported_types) as $typetmp) {
         echo "\t" . $typetmp . "\n";
     }
     echo "\n";
     $prompt = 'Are you sure you want to generate lots of test data?';
     if (!phutil_console_confirm($prompt, $default_no = true)) {
         return;
     }
     $argv = $args->getArg('args');
     if (count($argv) == 0 || count($argv) == 1 && $argv[0] == 'all') {
         $this->infinitelyGenerate($supported_types);
     } else {
         $new_supported_types = array();
         for ($i = 0; $i < count($argv); $i++) {
             $arg = $argv[$i];
             if (array_key_exists($arg, $supported_types)) {
                 $new_supported_types[$arg] = $supported_types[$arg];
             } else {
                 echo "The type " . $arg . " is not supported by the lipsum generator.\n";
             }
         }
         $this->infinitelyGenerate($new_supported_types);
     }
     echo "None of the input types were supported.\n";
     echo "The supported types are:\n";
     echo implode("\n", array_keys($supported_types));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:31,代码来源:PhabricatorLipsumGenerateWorkflow.php


示例9: 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


示例10: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $id = $args->getArg('id');
     if (!$id) {
         throw new PhutilArgumentUsageException(pht('Specify a public key to trust with --id.'));
     }
     $key = id(new PhabricatorAuthSSHKeyQuery())->setViewer($this->getViewer())->withIDs(array($id))->executeOne();
     if (!$key) {
         throw new PhutilArgumentUsageException(pht('No public key exists with ID "%s".', $id));
     }
     if ($key->getIsTrusted()) {
         throw new PhutilArgumentUsageException(pht('Public key with ID %s is already trusted.', $id));
     }
     if (!$key->getObject() instanceof AlmanacDevice) {
         throw new PhutilArgumentUsageException(pht('You can only trust keys associated with Almanac devices.'));
     }
     $handle = id(new PhabricatorHandleQuery())->setViewer($this->getViewer())->withPHIDs(array($key->getObject()->getPHID()))->executeOne();
     $console->writeOut("**<bg:red> %s </bg>**\n\n%s\n\n%s\n\n%s", pht('IMPORTANT!'), phutil_console_wrap(pht('Trusting a public key gives anyone holding the corresponding ' . 'private key complete, unrestricted access to all data in ' . 'Phabricator. The private key will be able to sign requests that ' . 'skip policy and security checks.')), phutil_console_wrap(pht('This is an advanced feature which should normally be used only ' . 'when building a Phabricator cluster. This feature is very ' . 'dangerous if misused.')), pht('This key is associated with device "%s".', $handle->getName()));
     $prompt = pht('Really trust this key?');
     if (!phutil_console_confirm($prompt)) {
         throw new PhutilArgumentUsageException(pht('User aborted workflow.'));
     }
     $key->setIsTrusted(1);
     $key->save();
     $console->writeOut("**<bg:green> %s </bg>** %s\n", pht('TRUSTED'), pht('Key %s has been marked as trusted.', $id));
 }
开发者ID:pugong,项目名称:phabricator,代码行数:27,代码来源:AlmanacManagementTrustKeyWorkflow.php


示例11: 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


示例12: execute

 public function execute(PhutilArgumentParser $args)
 {
     $ids = $args->getArg('id');
     if (!$ids) {
         throw new PhutilArgumentUsageException(pht('Specify one or more lease IDs to release with "%s".', '--id'));
     }
     $viewer = $this->getViewer();
     $drydock_phid = id(new PhabricatorDrydockApplication())->getPHID();
     $leases = id(new DrydockLeaseQuery())->setViewer($viewer)->withIDs($ids)->execute();
     PhabricatorWorker::setRunAllTasksInProcess(true);
     foreach ($ids as $id) {
         $lease = idx($leases, $id);
         if (!$lease) {
             echo tsprintf("%s\n", pht('Lease "%s" does not exist.', $id));
             continue;
         }
         if (!$lease->canRelease()) {
             echo tsprintf("%s\n", pht('Lease "%s" is not releasable.', $id));
             continue;
         }
         $command = DrydockCommand::initializeNewCommand($viewer)->setTargetPHID($lease->getPHID())->setAuthorPHID($drydock_phid)->setCommand(DrydockCommand::COMMAND_RELEASE)->save();
         $lease->scheduleUpdate();
         echo tsprintf("%s\n", pht('Scheduled release of lease "%s".', $id));
     }
 }
开发者ID:pugong,项目名称:phabricator,代码行数:25,代码来源:DrydockManagementReleaseLeaseWorkflow.php


示例13: 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


示例14: execute

 public function execute(PhutilArgumentParser $args)
 {
     $pids = $args->getArg('pids');
     $graceful = $args->getArg('graceful');
     $force = $args->getArg('force');
     return $this->executeStopCommand($pids, $graceful, $force);
 }
开发者ID:denghp,项目名称:phabricator,代码行数:7,代码来源:PhabricatorDaemonManagementStopWorkflow.php


示例15: 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


示例16: 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


示例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();
     $supported_types = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorTestDataGenerator')->execute();
     $console->writeOut("%s:\n\t%s\n", pht('These are the types of data you can generate'), implode("\n\t", array_keys($supported_types)));
     $prompt = pht('Are you sure you want to generate lots of test data?');
     if (!phutil_console_confirm($prompt, true)) {
         return;
     }
     $argv = $args->getArg('args');
     if (count($argv) == 0 || count($argv) == 1 && $argv[0] == 'all') {
         $this->infinitelyGenerate($supported_types);
     } else {
         $new_supported_types = array();
         for ($i = 0; $i < count($argv); $i++) {
             $arg = $argv[$i];
             if (array_key_exists($arg, $supported_types)) {
                 $new_supported_types[$arg] = $supported_types[$arg];
             } else {
                 $console->writeErr("%s\n", pht('The type %s is not supported by the lipsum generator.', $arg));
             }
         }
         $this->infinitelyGenerate($new_supported_types);
     }
     $console->writeOut("%s\n%s:\n%s\n", pht('None of the input types were supported.'), pht('The supported types are'), implode("\n", array_keys($supported_types)));
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:26,代码来源:PhabricatorLipsumGenerateWorkflow.php


示例19: 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


示例20: execute

 public function execute(PhutilArgumentParser $args)
 {
     $viewer = $this->getViewer();
     $names = $args->getArg('buildable');
     if (count($names) != 1) {
         throw new PhutilArgumentUsageException(pht('Specify exactly one buildable object, by object name.'));
     }
     $name = head($names);
     $buildable = id(new PhabricatorObjectQuery())->setViewer($viewer)->withNames($names)->executeOne();
     if (!$buildable) {
         throw new PhutilArgumentUsageException(pht('No such buildable "%s"!', $name));
     }
     if (!$buildable instanceof HarbormasterBuildableInterface) {
         throw new PhutilArgumentUsageException(pht('Object "%s" is not a buildable!', $name));
     }
     $plan_id = $args->getArg('plan');
     if (!$plan_id) {
         throw new PhutilArgumentUsageException(pht('Use --plan to specify a build plan to run.'));
     }
     $plan = id(new HarbormasterBuildPlanQuery())->setViewer($viewer)->withIDs(array($plan_id))->executeOne();
     if (!$plan) {
         throw new PhutilArgumentUsageException(pht('Build plan "%s" does not exist.', $plan_id));
     }
     $console = PhutilConsole::getConsole();
     $buildable = HarbormasterBuildable::initializeNewBuildable($viewer)->setIsManualBuildable(true)->setBuildablePHID($buildable->getHarbormasterBuildablePHID())->setContainerPHID($buildable->getHarbormasterContainerPHID())->save();
     $console->writeOut("%s\n", pht('Applying plan %s to new buildable %s...', $plan->getID(), 'B' . $buildable->getID()));
     $console->writeOut("\n    %s\n\n", PhabricatorEnv::getProductionURI('/B' . $buildable->getID()));
     PhabricatorWorker::setRunAllTasksInProcess(true);
     $buildable->applyPlan($plan);
     $console->writeOut("%s\n", pht('Done.'));
     return 0;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:32,代码来源:HarbormasterManagementBuildWorkflow.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP PhutilConsole类代码示例发布时间:2022-05-23
下一篇:
PHP PhrictionDocument类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap