Skip to content

Commit 25f74fe

Browse files
committed
feat: add occ command for task type toggling
Signed-off-by: Jana Peper <[email protected]>
1 parent 891e222 commit 25f74fe

File tree

5 files changed

+72
-0
lines changed

5 files changed

+72
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
4+
* SPDX-License-Identifier: AGPL-3.0-or-later
5+
*/
6+
namespace OC\Core\Command\TaskProcessing;
7+
8+
use OC\Core\Command\Base;
9+
use OCP\IConfig;
10+
use OCP\TaskProcessing\IManager;
11+
use Symfony\Component\Console\Input\InputArgument;
12+
use Symfony\Component\Console\Input\InputInterface;
13+
use Symfony\Component\Console\Output\OutputInterface;
14+
15+
class EnabledCommand extends Base {
16+
public function __construct(
17+
protected IManager $taskProcessingManager,
18+
private IConfig $config,
19+
) {
20+
parent::__construct();
21+
}
22+
23+
protected function configure() {
24+
$this
25+
->setName('taskprocessing:task:enabled')
26+
->setDescription('Enable or disable a task type')
27+
->addArgument(
28+
'task-type-id',
29+
InputArgument::REQUIRED,
30+
'ID of the task type to configure'
31+
)
32+
->addArgument(
33+
'enabled',
34+
InputArgument::REQUIRED,
35+
'status of the task type availability. Set 1 to enable and 0 to disable.'
36+
);
37+
parent::configure();
38+
}
39+
40+
protected function execute(InputInterface $input, OutputInterface $output): int {
41+
$enabled = (bool)$input->getArgument('enabled');
42+
$taskType = $input->getArgument('task-type-id');
43+
$json = $this->config->getAppValue('core', 'ai.taskprocessing_type_preferences');
44+
if ($json === '') {
45+
$taskTypeSettings = [];
46+
} else {
47+
$taskTypeSettings = json_decode($json, true);
48+
}
49+
if ($enabled) {
50+
$taskTypeSettings[$taskType] = true;
51+
} else {
52+
$taskTypeSettings[$taskType] = false;
53+
}
54+
55+
56+
$this->config->setAppValue('core', 'ai.taskprocessing_type_preferences', json_encode($taskTypeSettings));
57+
$this->writeArrayInOutputFormat($input, $output, $taskTypeSettings);
58+
return 0;
59+
}
60+
}

core/register_command.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@
147147
$application->add(Server::get(Command\FilesMetadata\Get::class));
148148

149149
$application->add(Server::get(Command\TaskProcessing\GetCommand::class));
150+
$application->add(Server::get(Command\TaskProcessing\EnabledCommand::class));
150151
$application->add(Server::get(Command\TaskProcessing\ListCommand::class));
151152
$application->add(Server::get(Command\TaskProcessing\Statistics::class));
152153

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,7 @@
12631263
'OC\\Core\\Command\\SystemTag\\Delete' => $baseDir . '/core/Command/SystemTag/Delete.php',
12641264
'OC\\Core\\Command\\SystemTag\\Edit' => $baseDir . '/core/Command/SystemTag/Edit.php',
12651265
'OC\\Core\\Command\\SystemTag\\ListCommand' => $baseDir . '/core/Command/SystemTag/ListCommand.php',
1266+
'OC\\Core\\Command\\TaskProcessing\\EnabledCommand' => $baseDir . '/core/Command/TaskProcessing/EnabledCommand.php',
12661267
'OC\\Core\\Command\\TaskProcessing\\GetCommand' => $baseDir . '/core/Command/TaskProcessing/GetCommand.php',
12671268
'OC\\Core\\Command\\TaskProcessing\\ListCommand' => $baseDir . '/core/Command/TaskProcessing/ListCommand.php',
12681269
'OC\\Core\\Command\\TaskProcessing\\Statistics' => $baseDir . '/core/Command/TaskProcessing/Statistics.php',

lib/composer/composer/autoload_psr4.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
'OC\\' => array($baseDir . '/lib/private'),
1111
'OCP\\' => array($baseDir . '/lib/public'),
1212
'NCU\\' => array($baseDir . '/lib/unstable'),
13+
'Bamarni\\Composer\\Bin\\' => array($vendorDir . '/bamarni/composer-bin-plugin/src'),
1314
'' => array($baseDir . '/lib/private/legacy'),
1415
);

lib/composer/composer/autoload_static.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
2121
array (
2222
'NCU\\' => 4,
2323
),
24+
'B' =>
25+
array (
26+
'Bamarni\\Composer\\Bin\\' => 21,
27+
),
2428
);
2529

2630
public static $prefixDirsPsr4 = array (
@@ -40,6 +44,10 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
4044
array (
4145
0 => __DIR__ . '/../../..' . '/lib/unstable',
4246
),
47+
'Bamarni\\Composer\\Bin\\' =>
48+
array (
49+
0 => __DIR__ . '/..' . '/bamarni/composer-bin-plugin/src',
50+
),
4351
);
4452

4553
public static $fallbackDirsPsr4 = array (
@@ -1304,6 +1312,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
13041312
'OC\\Core\\Command\\SystemTag\\Delete' => __DIR__ . '/../../..' . '/core/Command/SystemTag/Delete.php',
13051313
'OC\\Core\\Command\\SystemTag\\Edit' => __DIR__ . '/../../..' . '/core/Command/SystemTag/Edit.php',
13061314
'OC\\Core\\Command\\SystemTag\\ListCommand' => __DIR__ . '/../../..' . '/core/Command/SystemTag/ListCommand.php',
1315+
'OC\\Core\\Command\\TaskProcessing\\EnabledCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/EnabledCommand.php',
13071316
'OC\\Core\\Command\\TaskProcessing\\GetCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/GetCommand.php',
13081317
'OC\\Core\\Command\\TaskProcessing\\ListCommand' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/ListCommand.php',
13091318
'OC\\Core\\Command\\TaskProcessing\\Statistics' => __DIR__ . '/../../..' . '/core/Command/TaskProcessing/Statistics.php',

0 commit comments

Comments
 (0)