Browse Source

move get/delete commands to files namespace, make get take the output as argument instead of option

Signed-off-by: Robin Appelman <robin@icewind.nl>
tags/v27.0.0beta2
Robin Appelman 1 year ago
parent
commit
f9fb102f0b
No account linked to committer's email address

+ 2
- 0
apps/files/appinfo/info.xml View File

@@ -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>

+ 2
- 0
apps/files/composer/composer/autoload_classmap.php View File

@@ -27,7 +27,9 @@ return array(
'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',

+ 2
- 0
apps/files/composer/composer/autoload_static.php View File

@@ -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',

core/Command/Info/Delete.php → apps/files/lib/Command/Delete.php View File

@@ -21,8 +21,9 @@ declare(strict_types=1);
*
*/

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;
@@ -43,7 +44,7 @@ class Delete extends Command {

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");

core/Command/Info/Get.php → apps/files/lib/Command/Get.php View File

@@ -21,15 +21,14 @@ declare(strict_types=1);
*
*/

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 {
@@ -42,15 +41,15 @@ class Get extends Command {

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) {
@@ -63,13 +62,13 @@ class Get extends Command {
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 {

+ 0
- 2
core/register_command.php View File

@@ -105,8 +105,6 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) {

$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)));

Loading…
Cancel
Save