1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-01-24 13:38:18 +01:00

Minor tidying of ArcanistUploadWorkflow

Summary: Self-explanatory.

Test Plan: Eyeball it.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11556
This commit is contained in:
Joshua Spence 2015-02-01 21:51:12 +11:00
parent 3e63402fef
commit 589ee20a76

View file

@ -30,7 +30,7 @@ EOTEXT
public function getArguments() { public function getArguments() {
return array( return array(
'json' => array( 'json' => array(
'help' => 'Output upload information in JSON format.', 'help' => pht('Output upload information in JSON format.'),
), ),
'*' => 'paths', '*' => 'paths',
); );
@ -38,7 +38,8 @@ EOTEXT
protected function didParseArguments() { protected function didParseArguments() {
if (!$this->getArgument('paths')) { if (!$this->getArgument('paths')) {
throw new ArcanistUsageException('Specify one or more files to upload.'); throw new ArcanistUsageException(
pht('Specify one or more files to upload.'));
} }
$this->paths = $this->getArgument('paths'); $this->paths = $this->getArgument('paths');
@ -49,27 +50,19 @@ EOTEXT
return true; return true;
} }
private function getPaths() {
return $this->paths;
}
private function getJSON() {
return $this->json;
}
public function run() { public function run() {
$conduit = $this->getConduit(); $conduit = $this->getConduit();
$results = array(); $results = array();
foreach ($this->paths as $path) { foreach ($this->paths as $path) {
$name = basename($path); $name = basename($path);
$this->writeStatusMessage("Uploading '{$name}'...\n"); $this->writeStatusMessage(pht("Uploading '%s'...", $name)."\n");
try { try {
$data = Filesystem::readFile($path); $data = Filesystem::readFile($path);
} catch (FilesystemException $ex) { } catch (FilesystemException $ex) {
$this->writeStatusMessage( $this->writeStatusMessage(
"Unable to upload file: ".$ex->getMessage()."\n"); pht('Unable to upload file: %s.', $ex->getMessage())."\n");
$results[$path] = null; $results[$path] = null;
continue; continue;
} }
@ -88,16 +81,16 @@ EOTEXT
$results[$path] = $info; $results[$path] = $info;
if (!$this->getJSON()) { if (!$this->json) {
$id = $info['id']; $id = $info['id'];
echo " F{$id} {$name}: ".$info['uri']."\n\n"; echo " F{$id} {$name}: ".$info['uri']."\n\n";
} }
} }
if ($this->getJSON()) { if ($this->json) {
echo json_encode($results)."\n"; echo json_encode($results)."\n";
} else { } else {
$this->writeStatusMessage("Done.\n"); $this->writeStatusMessage(pht('Done.')."\n");
} }
return 0; return 0;