@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+59 -15
+2
src/__phutil_library_map__.php
··· 1832 1832 'PhabricatorFilesApplication' => 'applications/files/application/PhabricatorFilesApplication.php', 1833 1833 'PhabricatorFilesApplicationStorageEnginePanel' => 'applications/files/applicationpanel/PhabricatorFilesApplicationStorageEnginePanel.php', 1834 1834 'PhabricatorFilesConfigOptions' => 'applications/files/config/PhabricatorFilesConfigOptions.php', 1835 + 'PhabricatorFilesManagementCatWorkflow' => 'applications/files/management/PhabricatorFilesManagementCatWorkflow.php', 1835 1836 'PhabricatorFilesManagementCompactWorkflow' => 'applications/files/management/PhabricatorFilesManagementCompactWorkflow.php', 1836 1837 'PhabricatorFilesManagementEnginesWorkflow' => 'applications/files/management/PhabricatorFilesManagementEnginesWorkflow.php', 1837 1838 'PhabricatorFilesManagementMigrateWorkflow' => 'applications/files/management/PhabricatorFilesManagementMigrateWorkflow.php', ··· 5138 5139 'PhabricatorFilesApplication' => 'PhabricatorApplication', 5139 5140 'PhabricatorFilesApplicationStorageEnginePanel' => 'PhabricatorApplicationConfigurationPanel', 5140 5141 'PhabricatorFilesConfigOptions' => 'PhabricatorApplicationConfigOptions', 5142 + 'PhabricatorFilesManagementCatWorkflow' => 'PhabricatorFilesManagementWorkflow', 5141 5143 'PhabricatorFilesManagementCompactWorkflow' => 'PhabricatorFilesManagementWorkflow', 5142 5144 'PhabricatorFilesManagementEnginesWorkflow' => 'PhabricatorFilesManagementWorkflow', 5143 5145 'PhabricatorFilesManagementMigrateWorkflow' => 'PhabricatorFilesManagementWorkflow',
+39
src/applications/files/management/PhabricatorFilesManagementCatWorkflow.php
··· 1 + <?php 2 + 3 + final class PhabricatorFilesManagementCatWorkflow 4 + extends PhabricatorFilesManagementWorkflow { 5 + 6 + protected function didConstruct() { 7 + $this 8 + ->setName('cat') 9 + ->setSynopsis( 10 + pht('Print the contents of a file.')) 11 + ->setArguments( 12 + array( 13 + array( 14 + 'name' => 'names', 15 + 'wildcard' => true, 16 + ), 17 + )); 18 + } 19 + 20 + public function execute(PhutilArgumentParser $args) { 21 + $console = PhutilConsole::getConsole(); 22 + 23 + $names = $args->getArg('names'); 24 + if (count($names) > 1) { 25 + throw new PhutilArgumentUsageException( 26 + pht('Specify exactly one file to print, like "F123".')); 27 + } else if (!$names) { 28 + throw new PhutilArgumentUsageException( 29 + pht('Specify a file to print, like "F123".')); 30 + } 31 + 32 + $file = head($this->loadFilesWithNames($names)); 33 + 34 + echo $file->loadFileData(); 35 + 36 + return 0; 37 + } 38 + 39 + }
+18 -15
src/applications/files/management/PhabricatorFilesManagementWorkflow.php
··· 15 15 } 16 16 17 17 if ($names) { 18 - $query = id(new PhabricatorObjectQuery()) 19 - ->setViewer($this->getViewer()) 20 - ->withNames($names) 21 - ->withTypes(array(PhabricatorFileFilePHIDType::TYPECONST)); 18 + return $this->loadFilesWithNames($names); 19 + } 20 + 21 + return null; 22 + } 23 + 24 + protected function loadFilesWithNames(array $names) { 25 + $query = id(new PhabricatorObjectQuery()) 26 + ->setViewer($this->getViewer()) 27 + ->withNames($names) 28 + ->withTypes(array(PhabricatorFileFilePHIDType::TYPECONST)); 22 29 23 - $query->execute(); 24 - $files = $query->getNamedResults(); 30 + $query->execute(); 31 + $files = $query->getNamedResults(); 25 32 26 - foreach ($names as $name) { 27 - if (empty($files[$name])) { 28 - throw new PhutilArgumentUsageException( 29 - "No file '{$name}' exists!"); 30 - } 33 + foreach ($names as $name) { 34 + if (empty($files[$name])) { 35 + throw new PhutilArgumentUsageException( 36 + "No file '{$name}' exists!"); 31 37 } 32 - 33 - return array_values($files); 34 38 } 35 39 36 - return null; 40 + return array_values($files); 37 41 } 38 - 39 42 40 43 }