0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-04-28 19:13:08 +00:00
nextcloud_server/core/Command/Config/App/Base.php
Joas Schilling 7962df9427
fix(occ): Fix autocompletion of config:app:* commands
Signed-off-by: Joas Schilling <coding@schilljs.com>
2025-04-25 11:30:21 +02:00

36 lines
879 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Command\Config\App;
use OCP\IAppConfig;
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
abstract class Base extends \OC\Core\Command\Base {
public function __construct(
protected IAppConfig $appConfig,
) {
parent::__construct();
}
/**
* @param string $argumentName
* @param CompletionContext $context
* @return string[]
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'app') {
return $this->appConfig->getApps();
}
if ($argumentName === 'name') {
$appName = $context->getWordAtIndex($context->getWordIndex() - 1);
return $this->appConfig->getKeys($appName);
}
return [];
}
}