Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move get/delete commands to files namespace, make get take the output…
… as argument instead of option

Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Sep 6, 2023
commit f2d25c58740020b40854ba693a5f78ff2385fc7b
2 changes: 2 additions & 0 deletions apps/files/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
<command>OCA\Files\Command\TransferOwnership</command>
<command>OCA\Files\Command\ScanAppData</command>
<command>OCA\Files\Command\RepairTree</command>
<command>OCA\Files\Command\Get</command>
<command>OCA\Files\Command\Delete</command>
</commands>

<activity>
Expand Down
2 changes: 2 additions & 0 deletions apps/files/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
'OCA\\Files\\Capabilities' => $baseDir . '/../lib/Capabilities.php',
'OCA\\Files\\Collaboration\\Resources\\Listener' => $baseDir . '/../lib/Collaboration/Resources/Listener.php',
'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => $baseDir . '/../lib/Collaboration/Resources/ResourceProvider.php',
'OCA\\Files\\Command\\Delete' => $baseDir . '/../lib/Command/Delete.php',
'OCA\\Files\\Command\\DeleteOrphanedFiles' => $baseDir . '/../lib/Command/DeleteOrphanedFiles.php',
'OCA\\Files\\Command\\Get' => $baseDir . '/../lib/Command/Get.php',
'OCA\\Files\\Command\\RepairTree' => $baseDir . '/../lib/Command/RepairTree.php',
'OCA\\Files\\Command\\Scan' => $baseDir . '/../lib/Command/Scan.php',
'OCA\\Files\\Command\\ScanAppData' => $baseDir . '/../lib/Command/ScanAppData.php',
Expand Down
2 changes: 2 additions & 0 deletions apps/files/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ class ComposerStaticInitFiles
'OCA\\Files\\Capabilities' => __DIR__ . '/..' . '/../lib/Capabilities.php',
'OCA\\Files\\Collaboration\\Resources\\Listener' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/Listener.php',
'OCA\\Files\\Collaboration\\Resources\\ResourceProvider' => __DIR__ . '/..' . '/../lib/Collaboration/Resources/ResourceProvider.php',
'OCA\\Files\\Command\\Delete' => __DIR__ . '/..' . '/../lib/Command/Delete.php',
'OCA\\Files\\Command\\DeleteOrphanedFiles' => __DIR__ . '/..' . '/../lib/Command/DeleteOrphanedFiles.php',
'OCA\\Files\\Command\\Get' => __DIR__ . '/..' . '/../lib/Command/Get.php',
'OCA\\Files\\Command\\RepairTree' => __DIR__ . '/..' . '/../lib/Command/RepairTree.php',
'OCA\\Files\\Command\\Scan' => __DIR__ . '/..' . '/../lib/Command/Scan.php',
'OCA\\Files\\Command\\ScanAppData' => __DIR__ . '/..' . '/../lib/Command/ScanAppData.php',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
*
*/

namespace OC\Core\Command\Info;
namespace OCA\Files\Command;

use OC\Core\Command\Info\FileUtils;
use OCA\Files_Sharing\SharedStorage;
use OCP\Files\Folder;
use Symfony\Component\Console\Command\Command;
Expand All @@ -43,7 +44,7 @@ public function __construct(FileUtils $fileUtils) {

protected function configure(): void {
$this
->setName('info:file:delete')
->setName('files:delete')
->setDescription('Delete a file or folder')
->addArgument('file', InputArgument::REQUIRED, "File id or path")
->addOption('force', 'f', InputOption::VALUE_NONE, "Don't ask for configuration and don't output any warnings");
Expand Down
17 changes: 8 additions & 9 deletions core/Command/Info/Get.php → apps/files/lib/Command/Get.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
*
*/

namespace OC\Core\Command\Info;
namespace OCA\Files\Command;


use OC\Core\Command\Info\FileUtils;
use OCP\Files\File;
use OCP\Util;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class Get extends Command {
Expand All @@ -42,15 +41,15 @@ public function __construct(FileUtils $fileUtils) {

protected function configure(): void {
$this
->setName('info:file:get')
->setName('files:get')
->setDescription('Get the contents of a file')
->addArgument('file', InputArgument::REQUIRED, "File id or path")
->addOption('output', 'o', InputOption::VALUE_REQUIRED, "Target file to output to");
->addArgument('output', InputArgument::OPTIONAL, "Target file to output to, defaults to STDOUT");
}

public function execute(InputInterface $input, OutputInterface $output): int {
$fileInput = $input->getArgument('file');
$outputName = $input->getOption('output');
$outputName = $input->getArgument('output');
$node = $this->fileUtils->getNode($fileInput);

if (!$node) {
Expand All @@ -63,13 +62,13 @@ public function execute(InputInterface $input, OutputInterface $output): int {
if ($outputName === null && $isTTY && $node->getMimePart() !== 'text') {
$output->writeln([
"<error>Warning: Binary output can mess up your terminal</error>",
" Use '--output STDOUT' to output it to the terminal anyway",
" Or '--output <FILE>' to save to a file instead"
" Use <info>occ files:get $fileInput -</info> to output it to the terminal anyway",
" Or <info>occ files:get $fileInput <FILE></info> to save to a file instead"
]);
return 1;
}
$source = $node->fopen('r');
$target = (!$outputName || strtolower($outputName) === 'stdout') ? STDOUT : fopen($outputName, 'w');
$target = (!$outputName || strtolower($outputName) === '-') ? STDOUT : fopen($outputName, 'w');
stream_copy_to_stream($source, $target);
return 0;
} else {
Expand Down
2 changes: 0 additions & 2 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@

$application->add(\OC::$server->get(OC\Core\Command\Info\File::class));
$application->add(\OC::$server->get(OC\Core\Command\Info\Space::class));
$application->add(\OC::$server->get(OC\Core\Command\Info\Get::class));
$application->add(\OC::$server->get(OC\Core\Command\Info\Delete::class));

$application->add(new OC\Core\Command\Db\ConvertType(\OC::$server->getConfig(), new \OC\DB\ConnectionFactory(\OC::$server->getSystemConfig())));
$application->add(new OC\Core\Command\Db\ConvertMysqlToMB4(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), \OC::$server->getURLGenerator(), \OC::$server->get(LoggerInterface::class)));
Expand Down