Merge pull request #1476 from nextcloud/autocomplete-for-occ-app-commands
Autocomplete for occ app commands
This commit is contained in:
commit
ffaf2f3260
29 changed files with 558 additions and 36 deletions
2
3rdparty
2
3rdparty
|
@ -1 +1 @@
|
|||
Subproject commit f5555fef8e80d8380efb44dc8b7622a1de573c15
|
||||
Subproject commit cc365d1299570f1d0ca2e4e1eede5ead15dc9da3
|
|
@ -29,13 +29,15 @@ use OC\App\CodeChecker\CodeChecker;
|
|||
use OC\App\CodeChecker\EmptyCheck;
|
||||
use OC\App\CodeChecker\InfoChecker;
|
||||
use OC\App\InfoParser;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
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 CheckCode extends Command {
|
||||
class CheckCode extends Command implements CompletionAwareInterface {
|
||||
|
||||
/** @var InfoParser */
|
||||
private $infoParser;
|
||||
|
@ -197,4 +199,28 @@ class CheckCode extends Command {
|
|||
$output->writeln("<info>Deprecated file found: $updatePhp - please use repair steps</info>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
if ($optionName === 'checker') {
|
||||
return ['private', 'deprecation', 'strong-comparison'];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'app-id') {
|
||||
return \OC_App::getAllApps();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,12 +26,14 @@
|
|||
namespace OC\Core\Command\App;
|
||||
|
||||
use OCP\App\IAppManager;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Disable extends Command {
|
||||
class Disable extends Command implements CompletionAwareInterface {
|
||||
|
||||
/** @var IAppManager */
|
||||
protected $manager;
|
||||
|
@ -69,4 +71,25 @@ class Disable extends Command {
|
|||
$output->writeln('No such app enabled: ' . $appId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'app-id') {
|
||||
return array_diff(\OC_App::getEnabledApps(true, true), $this->manager->getAlwaysEnabledApps());
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,13 +26,16 @@
|
|||
namespace OC\Core\Command\App;
|
||||
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\IGroup;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
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 Enable extends Command {
|
||||
class Enable extends Command implements CompletionAwareInterface {
|
||||
|
||||
/** @var IAppManager */
|
||||
protected $manager;
|
||||
|
@ -81,4 +84,31 @@ class Enable extends Command {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
if ($optionName === 'groups') {
|
||||
return array_map(function(IGroup $group) {
|
||||
return $group->getGID();
|
||||
}, \OC::$server->getGroupManager()->search($context->getCurrentWord()));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'app-id') {
|
||||
$allApps = \OC_App::getAllApps();
|
||||
return array_diff($allApps, \OC_App::getEnabledApps(true, true));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
namespace OC\Core\Command\App;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
@ -60,4 +61,16 @@ class GetPath extends Base {
|
|||
// App not found, exit with non-zero
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'app') {
|
||||
return \OC_App::getAllApps();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace OC\Core\Command\App;
|
|||
|
||||
use OC\Core\Command\Base;
|
||||
use OCP\App\IAppManager;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
@ -117,4 +118,25 @@ class ListApps extends Base {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $completionContext
|
||||
* @return array
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $completionContext) {
|
||||
if ($optionName === 'shipped') {
|
||||
return ['true', 'false'];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,12 +23,14 @@
|
|||
|
||||
namespace OC\Core\Command;
|
||||
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Base extends Command {
|
||||
class Base extends Command implements CompletionAwareInterface {
|
||||
const OUTPUT_FORMAT_PLAIN = 'plain';
|
||||
const OUTPUT_FORMAT_JSON = 'json';
|
||||
const OUTPUT_FORMAT_JSON_PRETTY = 'json_pretty';
|
||||
|
@ -158,4 +160,25 @@ class Base extends Command {
|
|||
|
||||
return parent::run($input, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
if ($optionName === 'output') {
|
||||
return ['plain', 'json', 'json_pretty'];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
48
core/Command/Config/App/Base.php
Normal file
48
core/Command/Config/App/Base.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Core\Command\Config\App;
|
||||
|
||||
use OCP\IConfig;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
|
||||
abstract class Base extends \OC\Core\Command\Base {
|
||||
|
||||
/** * @var IConfig */
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'app') {
|
||||
return \OC_App::getAllApps();
|
||||
}
|
||||
|
||||
if ($argumentName === 'name') {
|
||||
$appName = $context->getWordAtIndex($context->getWordIndex() - 1);
|
||||
return $this->config->getAppKeys($appName);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace OC\Core\Command\Config\App;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCP\IConfig;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace OC\Core\Command\Config\App;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCP\IConfig;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace OC\Core\Command\Config\App;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OCP\IConfig;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
|
|
@ -23,12 +23,16 @@
|
|||
namespace OC\Core\Command\Config;
|
||||
|
||||
use OCP\IConfig;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\ShellPathCompletion;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Import extends Command {
|
||||
class Import extends Command implements CompletionAwareInterface {
|
||||
protected $validRootKeys = ['system', 'apps'];
|
||||
|
||||
/** @var IConfig */
|
||||
|
@ -193,4 +197,30 @@ class Import extends Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'file') {
|
||||
$helper = new ShellPathCompletion(
|
||||
$this->getName(),
|
||||
'file',
|
||||
Completion::TYPE_ARGUMENT
|
||||
);
|
||||
return $helper->run();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace OC\Core\Command\Config;
|
|||
use OC\Core\Command\Base;
|
||||
use OC\SystemConfig;
|
||||
use OCP\IAppConfig;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
@ -127,4 +128,16 @@ class ListConfigs extends Base {
|
|||
|
||||
return $configs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'app') {
|
||||
return array_merge(['all', 'system'], \OC_App::getAllApps());
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
78
core/Command/Config/System/Base.php
Normal file
78
core/Command/Config/System/Base.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Core\Command\Config\System;
|
||||
|
||||
use OC\SystemConfig;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
|
||||
abstract class Base extends \OC\Core\Command\Base {
|
||||
|
||||
/** @var SystemConfig */
|
||||
protected $systemConfig;
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'name') {
|
||||
$words = $this->getPreviousNames($context, $context->getWordIndex());
|
||||
if (empty($words)) {
|
||||
$completions = $this->systemConfig->getKeys();
|
||||
} else {
|
||||
$key = array_shift($words);
|
||||
$value = $this->systemConfig->getValue($key);
|
||||
$completions = array_keys($value);
|
||||
|
||||
while (!empty($words) && is_array($value)) {
|
||||
$key = array_shift($words);
|
||||
if (!isset($value[$key]) || !is_array($value[$key])) {
|
||||
break;
|
||||
}
|
||||
|
||||
$value = $value[$key];
|
||||
$completions = array_keys($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $completions;
|
||||
}
|
||||
return parent::completeArgumentValues($argumentName, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CompletionContext $context
|
||||
* @param int $currentIndex
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getPreviousNames(CompletionContext $context, $currentIndex) {
|
||||
$word = $context->getWordAtIndex($currentIndex - 1);
|
||||
if ($word === $this->getName() || $currentIndex <= 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$words = $this->getPreviousNames($context, $currentIndex - 1);
|
||||
$words[] = $word;
|
||||
return $words;
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace OC\Core\Command\Config\System;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OC\SystemConfig;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
namespace OC\Core\Command\Config\System;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OC\SystemConfig;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
|
||||
namespace OC\Core\Command\Config\System;
|
||||
|
||||
use OC\Core\Command\Base;
|
||||
use OC\SystemConfig;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
|
@ -196,4 +196,15 @@ class SetConfig extends Base {
|
|||
return $existingValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
if ($optionName === 'type') {
|
||||
return ['string', 'integer', 'double', 'boolean'];
|
||||
}
|
||||
return parent::completeOptionValues($optionName, $context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace OC\Core\Command\Db;
|
|||
use \OCP\IConfig;
|
||||
use OC\DB\Connection;
|
||||
use OC\DB\ConnectionFactory;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
|
@ -41,7 +43,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
|
||||
class ConvertType extends Command {
|
||||
class ConvertType extends Command implements CompletionAwareInterface {
|
||||
/**
|
||||
* @var \OCP\IConfig
|
||||
*/
|
||||
|
@ -350,4 +352,29 @@ class ConvertType extends Command {
|
|||
'dbpassword' => $password,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return possible values for the named option
|
||||
*
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return possible values for the named argument
|
||||
*
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'type') {
|
||||
return ['mysql', 'oci', 'pgsql'];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,12 +23,16 @@
|
|||
|
||||
namespace OC\Core\Command\Db;
|
||||
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\ShellPathCompletion;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class GenerateChangeScript extends Command {
|
||||
class GenerateChangeScript extends Command implements CompletionAwareInterface {
|
||||
protected function configure() {
|
||||
$this
|
||||
->setName('db:generate-change-script')
|
||||
|
@ -56,4 +60,30 @@ class GenerateChangeScript extends Command {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'schema-xml') {
|
||||
$helper = new ShellPathCompletion(
|
||||
$this->getName(),
|
||||
'schema-xml',
|
||||
Completion::TYPE_ARGUMENT
|
||||
);
|
||||
return $helper->run();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,13 +25,15 @@ namespace OC\Core\Command\L10n;
|
|||
|
||||
use DirectoryIterator;
|
||||
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class CreateJs extends Command {
|
||||
class CreateJs extends Command implements CompletionAwareInterface {
|
||||
|
||||
protected function configure() {
|
||||
$this
|
||||
|
@ -135,4 +137,32 @@ class CreateJs extends Command {
|
|||
|
||||
return array($TRANSLATIONS, $PLURAL_FORMS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return possible values for the named option
|
||||
*
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return possible values for the named argument
|
||||
*
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'app') {
|
||||
return \OC_App::getAllApps();
|
||||
} else if ($argumentName === 'lang') {
|
||||
$appName = $context->getWordAtIndex($context->getWordIndex() - 1);
|
||||
return $this->getAllLanguages(\OC_App::getAppPath($appName));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,13 +25,15 @@ namespace OC\Core\Command\Log;
|
|||
|
||||
use \OCP\IConfig;
|
||||
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\ShellPathCompletion;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class File extends Command {
|
||||
class File extends Command implements Completion\CompletionAwareInterface {
|
||||
|
||||
/** @var IConfig */
|
||||
protected $config;
|
||||
|
@ -125,4 +127,31 @@ class File extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
if ($optionName === 'file') {
|
||||
$helper = new ShellPathCompletion(
|
||||
$this->getName(),
|
||||
'file',
|
||||
Completion::TYPE_OPTION
|
||||
);
|
||||
return $helper->run();
|
||||
} else if ($optionName === 'rotate-size') {
|
||||
return [0];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,15 +24,15 @@
|
|||
|
||||
namespace OC\Core\Command\Log;
|
||||
|
||||
use \OCP\IConfig;
|
||||
|
||||
use OCP\IConfig;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class Manage extends Command {
|
||||
class Manage extends Command implements CompletionAwareInterface {
|
||||
|
||||
const DEFAULT_BACKEND = 'file';
|
||||
const DEFAULT_LOG_LEVEL = 2;
|
||||
|
@ -172,4 +172,29 @@ class Manage extends Command {
|
|||
}
|
||||
throw new \InvalidArgumentException('Invalid log level number');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
if ($optionName === 'backend') {
|
||||
return ['file', 'syslog', 'errorlog'];
|
||||
} else if ($optionName === 'level') {
|
||||
return ['debug', 'info', 'warning', 'error'];
|
||||
} else if ($optionName === 'timezone') {
|
||||
return \DateTimeZone::listIdentifiers();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
60
core/Command/TwoFactorAuth/Base.php
Normal file
60
core/Command/TwoFactorAuth/Base.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\Core\Command\TwoFactorAuth;
|
||||
|
||||
use OCP\IUserManager;
|
||||
use OCP\IUser;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
|
||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
|
||||
|
||||
class Base extends \OC\Core\Command\Base implements CompletionAwareInterface {
|
||||
|
||||
/** @var IUserManager */
|
||||
protected $userManager;
|
||||
|
||||
/**
|
||||
* Return possible values for the named option
|
||||
*
|
||||
* @param string $optionName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeOptionValues($optionName, CompletionContext $context) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return possible values for the named argument
|
||||
*
|
||||
* @param string $argumentName
|
||||
* @param CompletionContext $context
|
||||
* @return string[]
|
||||
*/
|
||||
public function completeArgumentValues($argumentName, CompletionContext $context) {
|
||||
if ($argumentName === 'uid') {
|
||||
return array_map(function(IUser $user) {
|
||||
return $user->getUID();
|
||||
}, $this->userManager->search($context->getCurrentWord(), 100));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
|
@ -23,8 +23,7 @@
|
|||
namespace OC\Core\Command\TwoFactorAuth;
|
||||
|
||||
use OC\Authentication\TwoFactorAuth\Manager;
|
||||
use OC\User\Manager as UserManager;
|
||||
use OC\Core\Command\Base;
|
||||
use OCP\IUserManager;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
@ -34,10 +33,10 @@ class Disable extends Base {
|
|||
/** @var Manager */
|
||||
private $manager;
|
||||
|
||||
/** @var UserManager */
|
||||
private $userManager;
|
||||
/** @var IUserManager */
|
||||
protected $userManager;
|
||||
|
||||
public function __construct(Manager $manager, UserManager $userManager) {
|
||||
public function __construct(Manager $manager, IUserManager $userManager) {
|
||||
parent::__construct('twofactorauth:disable');
|
||||
$this->manager = $manager;
|
||||
$this->userManager = $userManager;
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
namespace OC\Core\Command\TwoFactorAuth;
|
||||
|
||||
use OC\Authentication\TwoFactorAuth\Manager;
|
||||
use OC\User\Manager as UserManager;
|
||||
use OC\Core\Command\Base;
|
||||
use OCP\IUserManager;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
@ -34,10 +33,10 @@ class Enable extends Base {
|
|||
/** @var Manager */
|
||||
private $manager;
|
||||
|
||||
/** @var UserManager */
|
||||
private $userManager;
|
||||
/** @var IUserManager */
|
||||
protected $userManager;
|
||||
|
||||
public function __construct(Manager $manager, UserManager $userManager) {
|
||||
public function __construct(Manager $manager, IUserManager $userManager) {
|
||||
parent::__construct('twofactorauth:enable');
|
||||
$this->manager = $manager;
|
||||
$this->userManager = $userManager;
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
/** @var $application Symfony\Component\Console\Application */
|
||||
$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
|
||||
$application->add(new OC\Core\Command\Status);
|
||||
$application->add(new OC\Core\Command\Check(\OC::$server->getConfig()));
|
||||
$infoParser = new \OC\App\InfoParser(\OC::$server->getURLGenerator());
|
||||
|
|
|
@ -337,11 +337,13 @@ return array(
|
|||
'OC\\Core\\Command\\Background\\WebCron' => $baseDir . '/core/Command/Background/WebCron.php',
|
||||
'OC\\Core\\Command\\Base' => $baseDir . '/core/Command/Base.php',
|
||||
'OC\\Core\\Command\\Check' => $baseDir . '/core/Command/Check.php',
|
||||
'OC\\Core\\Command\\Config\\App\\Base' => $baseDir . '/core/Command/Config/App/Base.php',
|
||||
'OC\\Core\\Command\\Config\\App\\DeleteConfig' => $baseDir . '/core/Command/Config/App/DeleteConfig.php',
|
||||
'OC\\Core\\Command\\Config\\App\\GetConfig' => $baseDir . '/core/Command/Config/App/GetConfig.php',
|
||||
'OC\\Core\\Command\\Config\\App\\SetConfig' => $baseDir . '/core/Command/Config/App/SetConfig.php',
|
||||
'OC\\Core\\Command\\Config\\Import' => $baseDir . '/core/Command/Config/Import.php',
|
||||
'OC\\Core\\Command\\Config\\ListConfigs' => $baseDir . '/core/Command/Config/ListConfigs.php',
|
||||
'OC\\Core\\Command\\Config\\System\\Base' => $baseDir . '/core/Command/Config/System/Base.php',
|
||||
'OC\\Core\\Command\\Config\\System\\DeleteConfig' => $baseDir . '/core/Command/Config/System/DeleteConfig.php',
|
||||
'OC\\Core\\Command\\Config\\System\\GetConfig' => $baseDir . '/core/Command/Config/System/GetConfig.php',
|
||||
'OC\\Core\\Command\\Config\\System\\SetConfig' => $baseDir . '/core/Command/Config/System/SetConfig.php',
|
||||
|
@ -378,6 +380,7 @@ return array(
|
|||
'OC\\Core\\Command\\Security\\ListCertificates' => $baseDir . '/core/Command/Security/ListCertificates.php',
|
||||
'OC\\Core\\Command\\Security\\RemoveCertificate' => $baseDir . '/core/Command/Security/RemoveCertificate.php',
|
||||
'OC\\Core\\Command\\Status' => $baseDir . '/core/Command/Status.php',
|
||||
'OC\\Core\\Command\\TwoFactorAuth\\Base' => $baseDir . '/core/Command/TwoFactorAuth/Base.php',
|
||||
'OC\\Core\\Command\\TwoFactorAuth\\Disable' => $baseDir . '/core/Command/TwoFactorAuth/Disable.php',
|
||||
'OC\\Core\\Command\\TwoFactorAuth\\Enable' => $baseDir . '/core/Command/TwoFactorAuth/Enable.php',
|
||||
'OC\\Core\\Command\\Upgrade' => $baseDir . '/core/Command/Upgrade.php',
|
||||
|
|
|
@ -367,11 +367,13 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OC\\Core\\Command\\Background\\WebCron' => __DIR__ . '/../../..' . '/core/Command/Background/WebCron.php',
|
||||
'OC\\Core\\Command\\Base' => __DIR__ . '/../../..' . '/core/Command/Base.php',
|
||||
'OC\\Core\\Command\\Check' => __DIR__ . '/../../..' . '/core/Command/Check.php',
|
||||
'OC\\Core\\Command\\Config\\App\\Base' => __DIR__ . '/../../..' . '/core/Command/Config/App/Base.php',
|
||||
'OC\\Core\\Command\\Config\\App\\DeleteConfig' => __DIR__ . '/../../..' . '/core/Command/Config/App/DeleteConfig.php',
|
||||
'OC\\Core\\Command\\Config\\App\\GetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/App/GetConfig.php',
|
||||
'OC\\Core\\Command\\Config\\App\\SetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/App/SetConfig.php',
|
||||
'OC\\Core\\Command\\Config\\Import' => __DIR__ . '/../../..' . '/core/Command/Config/Import.php',
|
||||
'OC\\Core\\Command\\Config\\ListConfigs' => __DIR__ . '/../../..' . '/core/Command/Config/ListConfigs.php',
|
||||
'OC\\Core\\Command\\Config\\System\\Base' => __DIR__ . '/../../..' . '/core/Command/Config/System/Base.php',
|
||||
'OC\\Core\\Command\\Config\\System\\DeleteConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/DeleteConfig.php',
|
||||
'OC\\Core\\Command\\Config\\System\\GetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/GetConfig.php',
|
||||
'OC\\Core\\Command\\Config\\System\\SetConfig' => __DIR__ . '/../../..' . '/core/Command/Config/System/SetConfig.php',
|
||||
|
@ -408,6 +410,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
|||
'OC\\Core\\Command\\Security\\ListCertificates' => __DIR__ . '/../../..' . '/core/Command/Security/ListCertificates.php',
|
||||
'OC\\Core\\Command\\Security\\RemoveCertificate' => __DIR__ . '/../../..' . '/core/Command/Security/RemoveCertificate.php',
|
||||
'OC\\Core\\Command\\Status' => __DIR__ . '/../../..' . '/core/Command/Status.php',
|
||||
'OC\\Core\\Command\\TwoFactorAuth\\Base' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Base.php',
|
||||
'OC\\Core\\Command\\TwoFactorAuth\\Disable' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Disable.php',
|
||||
'OC\\Core\\Command\\TwoFactorAuth\\Enable' => __DIR__ . '/../../..' . '/core/Command/TwoFactorAuth/Enable.php',
|
||||
'OC\\Core\\Command\\Upgrade' => __DIR__ . '/../../..' . '/core/Command/Upgrade.php',
|
||||
|
|
|
@ -88,10 +88,14 @@ class Application {
|
|||
require_once __DIR__ . '/../../../core/register_command.php';
|
||||
if ($this->config->getSystemValue('installed', false)) {
|
||||
if (\OCP\Util::needUpgrade()) {
|
||||
$output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
|
||||
$output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
|
||||
if ($input->getArgument('command') !== '_completion') {
|
||||
$output->writeln("Nextcloud or one of the apps require upgrade - only a limited number of commands are available");
|
||||
$output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
|
||||
}
|
||||
} elseif ($this->config->getSystemValue('maintenance', false)) {
|
||||
$output->writeln("Nextcloud is in maintenance mode - no app have been loaded");
|
||||
if ($input->getArgument('command') !== '_completion') {
|
||||
$output->writeln("Nextcloud is in maintenance mode - no apps have been loaded");
|
||||
}
|
||||
} else {
|
||||
OC_App::loadApps();
|
||||
foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
|
||||
|
@ -106,10 +110,10 @@ class Application {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if ($input->getArgument('command') !== '_completion') {
|
||||
$output->writeln("Nextcloud is not installed - only a limited number of commands are available");
|
||||
}
|
||||
$input = new ArgvInput();
|
||||
|
||||
if ($input->getFirstArgument() !== 'check') {
|
||||
$errors = \OC_Util::checkServer(\OC::$server->getConfig());
|
||||
if (!empty($errors)) {
|
||||
|
|
Loading…
Reference in a new issue