Page MenuHomePhabricator

D11907.diff
No OneTemporary

D11907.diff

diff --git a/src/applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php b/src/applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php
--- a/src/applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php
+++ b/src/applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php
@@ -7,7 +7,7 @@
$this
->setName('generate')
->setExamples('**generate**')
- ->setSynopsis('Generate some lipsum.')
+ ->setSynopsis(pht('Generate some lipsum.'))
->setArguments(
array(
array(
@@ -18,47 +18,60 @@
}
public function execute(PhutilArgumentParser $args) {
+ $console = PhutilConsole::getConsole();
+
$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)) {
+
+ $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')) {
+ 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++) {
+ for ($i = 0; $i < count($argv); $i++) {
$arg = $argv[$i];
if (array_key_exists($arg, $supported_types)) {
- $new_supported_types[$arg] = $supported_types[$arg];
+ $new_supported_types[$arg] = $supported_types[$arg];
} else {
- echo "The type ".$arg." is not supported by the lipsum generator.\n";
+ $console->writeErr(
+ "%s\n",
+ pht(
+ 'The type %s is not supported by the lipsum generator.',
+ $arg));
}
}
$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));
+
+ $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)));
}
protected function infinitelyGenerate(array $supported_types) {
+ $console = PhutilConsole::getConsole();
+
if (count($supported_types) == 0) {
- echo "None of the input types were supported.\n";
return;
}
- echo 'GENERATING: ';
- echo strtoupper(implode(' , ', array_keys($supported_types)));
- echo "\n";
+ $console->writeOut(
+ "%s: %s\n",
+ pht('GENERATING'),
+ implode(', ', array_keys($supported_types)));
+
while (true) {
$type = $supported_types[array_rand($supported_types)];
$admin = $this->getViewer();
@@ -69,8 +82,11 @@
->setViewer($admin)
->withPHIDs(array($object->getPHID()))
->executeOne();
- echo "Generated ".$handle->getTypeName().": ".
- $handle->getFullName()."\n";
+
+ $console->writeOut(
+ "%s: %s\n",
+ pht('Generated %s', $handle->getTypeName()),
+ $handle->getFullName());
usleep(200000);
}

File Metadata

Mime Type
text/plain
Expires
May 24 2024, 5:20 AM (5 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6276151
Default Alt Text
D11907.diff (3 KB)

Event Timeline