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


PHP phutil_console_confirm函数代码示例

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


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

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

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

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

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

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

示例6: handleMessage

 public function handleMessage(PhutilConsoleMessage $message)
 {
     $data = $message->getData();
     $type = $message->getType();
     switch ($type) {
         case PhutilConsoleMessage::TYPE_CONFIRM:
             $ok = phutil_console_confirm($data['prompt'], !$data['default']);
             return $this->buildMessage(PhutilConsoleMessage::TYPE_INPUT, $ok);
         case PhutilConsoleMessage::TYPE_PROMPT:
             $response = phutil_console_prompt($data['prompt'], idx($data, 'history'));
             return $this->buildMessage(PhutilConsoleMessage::TYPE_INPUT, $response);
         case PhutilConsoleMessage::TYPE_OUT:
             $this->writeText(STDOUT, $data);
             return null;
         case PhutilConsoleMessage::TYPE_ERR:
             $this->writeText(STDERR, $data);
             return null;
         case PhutilConsoleMessage::TYPE_LOG:
             if ($this->enableLog) {
                 $this->writeText(STDERR, $data);
             }
             return null;
         default:
             if ($this->handler) {
                 return call_user_func($this->handler, $message);
             } else {
                 throw new Exception("Received unknown console message of type '{$type}'.");
             }
     }
 }
开发者ID:chaozhang80,项目名称:tool-package,代码行数:30,代码来源:PhutilConsoleServer.php

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

示例8: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $repos = id(new PhabricatorRepositoryQuery())->setViewer($this->getViewer())->execute();
     if (!$repos) {
         $console->writeErr("%s\n", pht('There are no repositories.'));
         return 0;
     }
     $from = $args->getArg('from');
     if (!strlen($from)) {
         throw new Exception(pht('You must specify a path prefix to move from with --from.'));
     }
     $to = $args->getArg('to');
     if (!strlen($to)) {
         throw new Exception(pht('You must specify a path prefix to move to with --to.'));
     }
     $rows = array();
     $any_changes = false;
     foreach ($repos as $repo) {
         $src = $repo->getLocalPath();
         $row = array('repository' => $repo, 'move' => false, 'monogram' => $repo->getMonogram(), 'src' => $src, 'dst' => '');
         if (strncmp($src, $from, strlen($from))) {
             $row['action'] = pht('Ignore');
         } else {
             $dst = $to . substr($src, strlen($from));
             $row['action'] = phutil_console_format('**%s**', pht('Move'));
             $row['dst'] = $dst;
             $row['move'] = true;
             $any_changes = true;
         }
         $rows[] = $row;
     }
     $table = id(new PhutilConsoleTable())->addColumn('action', array('title' => pht('Action')))->addColumn('monogram', array('title' => pht('Repository')))->addColumn('src', array('title' => pht('Src')))->addColumn('dst', array('title' => pht('dst')))->setBorders(true);
     foreach ($rows as $row) {
         $display = array_select_keys($row, array('action', 'monogram', 'src', 'dst'));
         $table->addRow($display);
     }
     $table->draw();
     if (!$any_changes) {
         $console->writeOut(pht('No matching repositories.') . "\n");
         return 0;
     }
     $prompt = pht('Apply these changes?');
     if (!phutil_console_confirm($prompt)) {
         throw new Exception(pht('Declining to apply changes.'));
     }
     foreach ($rows as $row) {
         if (empty($row['move'])) {
             continue;
         }
         $repo = $row['repository'];
         $details = $repo->getDetails();
         $details['local-path'] = $row['dst'];
         queryfx($repo->establishConnection('w'), 'UPDATE %T SET details = %s WHERE id = %d', $repo->getTableName(), phutil_json_encode($details), $repo->getID());
     }
     $console->writeOut(pht('Applied changes.') . "\n");
     return 0;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:58,代码来源:PhabricatorRepositoryManagementMovePathsWorkflow.php

示例9: execute

 public function execute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     $viewer = $this->getViewer();
     $subscription_phid = $args->getArg('subscription');
     if (!$subscription_phid) {
         throw new PhutilArgumentUsageException(pht('Specify which subscription to invoice with %s.', '--subscription'));
     }
     $subscription = id(new PhortuneSubscriptionQuery())->setViewer($viewer)->withPHIDs(array($subscription_phid))->needTriggers(true)->executeOne();
     if (!$subscription) {
         throw new PhutilArgumentUsageException(pht('Unable to load subscription with PHID "%s".', $subscription_phid));
     }
     $now = $args->getArg('now');
     $now = $this->parseTimeArgument($now);
     if (!$now) {
         $now = PhabricatorTime::getNow();
     }
     $time_guard = PhabricatorTime::pushTime($now, date_default_timezone_get());
     $console->writeOut("%s\n", pht('Set current time to %s.', phabricator_datetime(PhabricatorTime::getNow(), $viewer)));
     $auto_range = $args->getArg('auto-range');
     $last_arg = $args->getArg('last');
     $next_arg = $args->getARg('next');
     if (!$auto_range && !$last_arg && !$next_arg) {
         throw new PhutilArgumentUsageException(pht('Specify a billing range with %s and %s, or use %s.', '--last', '--next', '--auto-range'));
     } else {
         if (!$auto_range & (!$last_arg || !$next_arg)) {
             throw new PhutilArgumentUsageException(pht('When specifying %s or %s, you must specify both arguments ' . 'to define the beginning and end of the billing range.', '--last', '--next'));
         } else {
             if (!$auto_range && ($last_arg && $next_arg)) {
                 $last_time = $this->parseTimeArgument($args->getArg('last'));
                 $next_time = $this->parseTimeArgument($args->getArg('next'));
             } else {
                 if ($auto_range && ($last_arg || $next_arg)) {
                     throw new PhutilArgumentUsageException(pht('Use either %s or %s and %s to specify the ' . 'billing range, but not both.', '--auto-range', '--last', '--next'));
                 } else {
                     $trigger = $subscription->getTrigger();
                     $event = $trigger->getEvent();
                     if (!$event) {
                         throw new PhutilArgumentUsageException(pht('Unable to calculate %s, this subscription has not been ' . 'scheduled for billing yet. Wait for the trigger daemon to ' . 'schedule the subscription.', '--auto-range'));
                     }
                     $last_time = $event->getLastEventEpoch();
                     $next_time = $event->getNextEventEpoch();
                 }
             }
         }
     }
     $console->writeOut("%s\n", pht('Preparing to invoice subscription "%s" from %s to %s.', $subscription->getSubscriptionName(), $last_time ? phabricator_datetime($last_time, $viewer) : pht('subscription creation'), phabricator_datetime($next_time, $viewer)));
     PhabricatorWorker::setRunAllTasksInProcess(true);
     if (!$args->getArg('force')) {
         $console->writeOut("**<bg:yellow> %s </bg>**\n%s\n", pht('WARNING'), phutil_console_wrap(pht('Manually invoicing will double bill payment accounts if the ' . 'range overlaps an existing or future invoice. This script is ' . 'intended for testing and development, and should not be part ' . 'of routine billing operations. If you continue, you may ' . 'incorrectly overcharge customers.')));
         if (!phutil_console_confirm(pht('Really invoice this subscription?'))) {
             throw new Exception(pht('Declining to invoice.'));
         }
     }
     PhabricatorWorker::scheduleTask('PhortuneSubscriptionWorker', array('subscriptionPHID' => $subscription->getPHID(), 'trigger.last-epoch' => $last_time, 'trigger.this-epoch' => $next_time, 'manual' => true), array('objectPHID' => $subscription->getPHID()));
     return 0;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:57,代码来源:PhabricatorPhortuneManagementInvoiceWorkflow.php

示例10: execute

 public function execute(PhutilArgumentParser $args)
 {
     $viewer = $this->getViewer();
     $ids = $args->getArg('id');
     $active = $args->getArg('active');
     if (!$ids && !$active) {
         throw new PhutilArgumentUsageException(pht('Use --id or --active to select builds.'));
     }
     if ($ids && $active) {
         throw new PhutilArgumentUsageException(pht('Use one of --id or --active to select builds, but not both.'));
     }
     $query = id(new HarbormasterBuildQuery())->setViewer($viewer);
     if ($ids) {
         $query->withIDs($ids);
     } else {
         $query->withBuildStatuses(HarbormasterBuildStatus::getActiveStatusConstants());
     }
     $builds = $query->execute();
     $console = PhutilConsole::getConsole();
     $count = count($builds);
     if (!$count) {
         $console->writeOut("%s\n", pht('No builds to restart.'));
         return 0;
     }
     $prompt = pht('Restart %s build(s)?', new PhutilNumber($count));
     if (!phutil_console_confirm($prompt)) {
         $console->writeOut("%s\n", pht('Cancelled.'));
         return 1;
     }
     $app_phid = id(new PhabricatorHarbormasterApplication())->getPHID();
     $editor = id(new HarbormasterBuildTransactionEditor())->setActor($viewer)->setActingAsPHID($app_phid)->setContentSource($this->newContentSource());
     foreach ($builds as $build) {
         $console->writeOut("<bg:blue> %s </bg> %s\n", pht('RESTARTING'), pht('Build %d: %s', $build->getID(), $build->getName()));
         if (!$build->canRestartBuild()) {
             $console->writeOut("<bg:yellow> %s </bg> %s\n", pht('INVALID'), pht('Cannot be restarted.'));
             continue;
         }
         $xactions = array();
         $xactions[] = id(new HarbormasterBuildTransaction())->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)->setNewValue(HarbormasterBuildCommand::COMMAND_RESTART);
         try {
             $editor->applyTransactions($build, $xactions);
         } catch (Exception $e) {
             $message = phutil_console_wrap($e->getMessage(), 2);
             $console->writeOut("<bg:red> %s </bg>\n%s\n", pht('FAILED'), $message);
             continue;
         }
         $console->writeOut("<bg:green> %s </bg>\n", pht('SUCCESS'));
     }
     return 0;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:50,代码来源:HarbormasterManagementRestartWorkflow.php

示例11: execute

 public function execute(PhutilArgumentParser $args)
 {
     $config_key = 'phabricator.developer-mode';
     if (!PhabricatorEnv::getEnvConfig($config_key)) {
         throw new PhutilArgumentUsageException(pht('lipsum is a development and testing tool and may only be run ' . 'on installs in developer mode. Enable "%s" in your configuration ' . 'to enable lipsum.', $config_key));
     }
     $all_generators = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorTestDataGenerator')->execute();
     $argv = $args->getArg('args');
     $all = 'all';
     if (!$argv) {
         $names = mpull($all_generators, 'getGeneratorName');
         sort($names);
         $list = id(new PhutilConsoleList())->setWrap(false)->addItems($names);
         id(new PhutilConsoleBlock())->addParagraph(pht('Choose which type or types of test data you want to generate, ' . 'or select "%s".', $all))->addList($list)->draw();
         return 0;
     }
     $generators = array();
     foreach ($argv as $arg_original) {
         $arg = phutil_utf8_strtolower($arg_original);
         $match = false;
         foreach ($all_generators as $generator) {
             $name = phutil_utf8_strtolower($generator->getGeneratorName());
             if ($arg == $all) {
                 $generators[] = $generator;
                 $match = true;
                 break;
             }
             if (strpos($name, $arg) !== false) {
                 $generators[] = $generator;
                 $match = true;
                 break;
             }
         }
         if (!$match) {
             throw new PhutilArgumentUsageException(pht('Argument "%s" does not match the name of any generators.', $arg_original));
         }
     }
     echo tsprintf("**<bg:blue> %s </bg>** %s\n", pht('GENERATORS'), pht('Selected generators: %s.', implode(', ', mpull($generators, 'getGeneratorName'))));
     echo tsprintf("**<bg:yellow> %s </bg>** %s\n", pht('WARNING'), pht('This command generates synthetic test data, including user ' . 'accounts. It is intended for use in development environments ' . 'so you can test features more easily. There is no easy way to ' . 'delete this data or undo the effects of this command. If you run ' . 'it in a production environment, it will pollute your data with ' . 'large amounts of meaningless garbage that you can not get rid of.'));
     $prompt = pht('Are you sure you want to generate piles of garbage?');
     if (!phutil_console_confirm($prompt, true)) {
         return;
     }
     echo tsprintf("**<bg:green> %s </bg>** %s\n", pht('LIPSUM'), pht('Generating synthetic test objects forever. ' . 'Use ^C to stop when satisfied.'));
     $this->generate($generators);
 }
开发者ID:truSense,项目名称:phabricator,代码行数:46,代码来源:PhabricatorLipsumGenerateWorkflow.php

示例12: didExecute

 public function didExecute(PhutilArgumentParser $args)
 {
     $console = PhutilConsole::getConsole();
     if (!$this->isDryRun() && !$this->isForce()) {
         $console->writeOut(phutil_console_wrap(pht('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(pht('Permanently destroy all data?'))) {
             $console->writeOut("%s\n", pht('Cancelled.'));
             exit(1);
         }
         if (!phutil_console_confirm(pht('Really destroy all data forever?'))) {
             $console->writeOut("%s\n", pht('Cancelled.'));
             exit(1);
         }
     }
     $apis = $this->getMasterAPIs();
     foreach ($apis as $api) {
         $patches = $this->getPatches();
         if ($args->getArg('unittest-fixtures')) {
             $conn = $api->getConn(null);
             $databases = queryfx_all($conn, 'SELECT DISTINCT(TABLE_SCHEMA) AS db ' . 'FROM INFORMATION_SCHEMA.TABLES ' . 'WHERE TABLE_SCHEMA LIKE %>', PhabricatorTestCase::NAMESPACE_PREFIX);
             $databases = ipull($databases, 'db');
         } else {
             $databases = $api->getDatabaseList($patches);
             $databases[] = $api->getDatabaseName('meta_data');
             // These are legacy databases that were dropped long ago. See T2237.
             $databases[] = $api->getDatabaseName('phid');
             $databases[] = $api->getDatabaseName('directory');
         }
         foreach ($databases as $database) {
             if ($this->isDryRun()) {
                 $console->writeOut("%s\n", pht("DRYRUN: Would drop database '%s'.", $database));
             } else {
                 $console->writeOut("%s\n", pht("Dropping database '%s'...", $database));
                 queryfx($api->getConn(null), 'DROP DATABASE IF EXISTS %T', $database);
             }
         }
         if (!$this->isDryRun()) {
             $console->writeOut("%s\n", pht('Storage on "%s" was destroyed.', $api->getRef()->getRefKey()));
         }
     }
     return 0;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:42,代码来源:PhabricatorStorageManagementDestroyWorkflow.php

示例13: 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();
     if ($args->getArg('unittest-fixtures')) {
         $conn = $api->getConn(null);
         $databases = queryfx_all($conn, 'SELECT DISTINCT(TABLE_SCHEMA) AS db ' . 'FROM INFORMATION_SCHEMA.TABLES ' . 'WHERE TABLE_SCHEMA LIKE %>', PhabricatorTestCase::NAMESPACE_PREFIX);
         $databases = ipull($databases, 'db');
     } else {
         $databases = $api->getDatabaseList($patches);
         $databases[] = $api->getDatabaseName('meta_data');
         // These are legacy databases that were dropped long ago. See T2237.
         $databases[] = $api->getDatabaseName('phid');
         $databases[] = $api->getDatabaseName('directory');
     }
     foreach ($databases as $database) {
         if ($is_dry) {
             echo "DRYRUN: Would drop database '{$database}'.\n";
         } else {
             echo "Dropping database '{$database}'...\n";
             queryfx($api->getConn(null), 'DROP DATABASE IF EXISTS %T', $database);
         }
     }
     if (!$is_dry) {
         echo "Storage was destroyed.\n";
     }
     return 0;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:41,代码来源:PhabricatorStorageManagementDestroyWorkflow.php

示例14: run

 public function run()
 {
     $is_show = $this->getArgument('show');
     $repository_api = $this->getRepositoryAPI();
     if (!$is_show) {
         if (!$repository_api->supportsAmend()) {
             throw new ArcanistUsageException(pht("You may only run '%s' in a git or hg " . "(version 2.2 or newer) working copy.", 'arc amend'));
         }
         if ($this->isHistoryImmutable()) {
             throw new ArcanistUsageException(pht('This project is marked as adhering to a conservative history ' . 'mutability doctrine (having an immutable local history), which ' . 'precludes amending commit messages.'));
         }
         if ($repository_api->getUncommittedChanges()) {
             throw new ArcanistUsageException(pht('You have uncommitted changes in this branch. Stage and commit ' . '(or revert) them before proceeding.'));
         }
     }
     $revision_id = null;
     if ($this->getArgument('revision')) {
         $revision_id = $this->normalizeRevisionID($this->getArgument('revision'));
     }
     $repository_api->setBaseCommitArgumentRules('arc:this');
     $in_working_copy = $repository_api->loadWorkingCopyDifferentialRevisions($this->getConduit(), array('status' => 'status-any'));
     $in_working_copy = ipull($in_working_copy, null, 'id');
     if (!$revision_id) {
         if (count($in_working_copy) == 0) {
             throw new ArcanistUsageException(pht("No revision specified with '%s', and no revisions found " . "in the working copy. Use '%s' to specify which revision " . "you want to amend.", '--revision', '--revision <id>'));
         } else {
             if (count($in_working_copy) > 1) {
                 $message = pht("More than one revision was found in the working copy:\n%s\n" . "Use '%s' to specify which revision you want to amend.", $this->renderRevisionList($in_working_copy), '--revision <id>');
                 throw new ArcanistUsageException($message);
             } else {
                 $revision_id = key($in_working_copy);
                 $revision = $in_working_copy[$revision_id];
                 if ($revision['authorPHID'] != $this->getUserPHID()) {
                     $other_author = $this->getConduit()->callMethodSynchronous('user.query', array('phids' => array($revision['authorPHID'])));
                     $other_author = ipull($other_author, 'userName', 'phid');
                     $other_author = $other_author[$revision['authorPHID']];
                     $rev_title = $revision['title'];
                     $ok = phutil_console_confirm(pht("You are amending the revision '%s' but you are not " . "the author. Amend this revision by %s?", "D{$revision_id}: {$rev_title}", $other_author));
                     if (!$ok) {
                         throw new ArcanistUserAbortException();
                     }
                 }
             }
         }
     }
     $conduit = $this->getConduit();
     try {
         $message = $conduit->callMethodSynchronous('differential.getcommitmessage', array('revision_id' => $revision_id, 'edit' => false));
     } catch (ConduitClientException $ex) {
         if (strpos($ex->getMessage(), 'ERR_NOT_FOUND') === false) {
             throw $ex;
         } else {
             throw new ArcanistUsageException(pht("Revision '%s' does not exist.", "D{$revision_id}"));
         }
     }
     $revision = $conduit->callMethodSynchronous('differential.query', array('ids' => array($revision_id)));
     if (empty($revision)) {
         throw new Exception(pht("Failed to lookup information for '%s'!", "D{$revision_id}"));
     }
     $revision = head($revision);
     $revision_title = $revision['title'];
     if (!$is_show) {
         if ($revision_id && empty($in_working_copy[$revision_id])) {
             $ok = phutil_console_confirm(pht("The revision '%s' does not appear to be in the working copy. Are " . "you sure you want to amend HEAD with the commit message for '%s'?", "D{$revision_id}", "D{$revision_id}: {$revision_title}"));
             if (!$ok) {
                 throw new ArcanistUserAbortException();
             }
         }
     }
     if ($is_show) {
         echo $message . "\n";
     } else {
         echo pht("Amending commit message to reflect revision %s.\n", phutil_console_format('**D%d: %s**', $revision_id, $revision_title));
         $repository_api->amendCommit($message);
     }
     return 0;
 }
开发者ID:barcelonascience,项目名称:arcanist,代码行数:77,代码来源:ArcanistAmendWorkflow.php

示例15: define

define('SCHEMA_VERSION_TABLE_NAME', 'schema_version');
// TODO: getopt() is super terrible, move to something less terrible.
$options = getopt('fhv:u:p:') + array('v' => null, 'u' => null, 'p' => null);
foreach (array('h', 'f') as $key) {
    // By default, these keys are set to 'false' to indicate that the flag was
    // passed.
    if (array_key_exists($key, $options)) {
        $options[$key] = true;
    }
}
if (!empty($options['h']) || $options['v'] && !is_numeric($options['v'])) {
    usage();
}
if (empty($options['f'])) {
    echo phutil_console_wrap("Before running this script, you should take down the Phabricator web " . "interface and stop any running Phabricator daemons.");
    if (!phutil_console_confirm('Are you ready to continue?')) {
        echo "Cancelled.\n";
        exit(1);
    }
}
// Use always the version from the commandline if it is defined
$next_version = isset($options['v']) ? (int) $options['v'] : null;
$conf = DatabaseConfigurationProvider::getConfiguration();
if ($options['u']) {
    $conn_user = $options['u'];
    $conn_pass = $options['p'];
} else {
    $conn_user = $conf->getUser();
    $conn_pass = $conf->getPassword();
}
$conn_host = $conf->getHost();
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:31,代码来源:upgrade_schema.php


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