1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-22 19:49:02 +01:00
phorge-phorge/src/applications/files/management/PhabricatorFilesManagementCatWorkflow.php
epriestley 6c3552f939 Add bin/files cat to print a file to stdout
Summary:
Ref T7149. This makes debugging some of this stuff a bit easier by removing the HTTP part in the middle.

Particularly, I anticipate having this stream data chunk-by-chunk in the near future.

Test Plan: Ran `files cat F23`, got output.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: joshuaspence, epriestley

Maniphest Tasks: T7149

Differential Revision: https://secure.phabricator.com/D12062
2015-03-13 11:30:13 -07:00

39 lines
916 B
PHP

<?php
final class PhabricatorFilesManagementCatWorkflow
extends PhabricatorFilesManagementWorkflow {
protected function didConstruct() {
$this
->setName('cat')
->setSynopsis(
pht('Print the contents of a file.'))
->setArguments(
array(
array(
'name' => 'names',
'wildcard' => true,
),
));
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
$names = $args->getArg('names');
if (count($names) > 1) {
throw new PhutilArgumentUsageException(
pht('Specify exactly one file to print, like "F123".'));
} else if (!$names) {
throw new PhutilArgumentUsageException(
pht('Specify a file to print, like "F123".'));
}
$file = head($this->loadFilesWithNames($names));
echo $file->loadFileData();
return 0;
}
}