Changeset View
Changeset View
Standalone View
Standalone View
src/workflow/ArcanistWeldWorkflow.php
<?php | <?php | ||||
final class ArcanistWeldWorkflow extends ArcanistWorkflow { | final class ArcanistWeldWorkflow | ||||
extends ArcanistArcWorkflow { | |||||
public function getWorkflowName() { | public function getWorkflowName() { | ||||
return 'weld'; | return 'weld'; | ||||
} | } | ||||
public function getCommandSynopses() { | public function getWorkflowInformation() { | ||||
return phutil_console_format(<<<EOTEXT | $help = pht(<<<EOTEXT | ||||
**weld** [options] __file__ __file__ ... | Robustly fuse two or more files together. The resulting joint is much stronger | ||||
than the one created by tools like __cat__. | |||||
EOTEXT | EOTEXT | ||||
); | ); | ||||
} | |||||
public function getCommandHelp() { | return $this->newWorkflowInformation() | ||||
return phutil_console_format(<<<EOTEXT | ->setSynopsis(pht('Robustly fuse files together.')) | ||||
Robustly fuse two or more files together. The resulting joint is | ->addExample('**weld** [options] -- __file__ __file__ ...') | ||||
much stronger than the one created by tools like __cat__. | ->setHelp($help); | ||||
EOTEXT | |||||
); | |||||
} | } | ||||
public function getArguments() { | public function getWorkflowArguments() { | ||||
return array( | return array( | ||||
'*' => 'files', | $this->newWorkflowArgument('files') | ||||
->setWildcard(true), | |||||
); | ); | ||||
} | } | ||||
public function run() { | public function runWorkflow() { | ||||
$files = $this->getArgument('files'); | $files = $this->getArgument('files'); | ||||
if (count($files) < 2) { | if (count($files) < 2) { | ||||
throw new ArcanistUsageException( | throw new PhutilArgumentUsageException( | ||||
pht('Specify two or more files to weld together.')); | pht('Specify two or more files to weld together.')); | ||||
} | } | ||||
$buffer = array(); | $buffer = array(); | ||||
foreach ($files as $file) { | foreach ($files as $file) { | ||||
$data = Filesystem::readFile($file); | $data = Filesystem::readFile($file); | ||||
if (!strlen($data)) { | if (!strlen($data)) { | ||||
continue; | continue; | ||||
▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines |