Skip to content

Commit 6cf1cbc

Browse files
chore: Add category/class type parameter to setupchecks cmd
Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent 85a714f commit 6cf1cbc

1 file changed

Lines changed: 32 additions & 1 deletion

File tree

core/Command/SetupChecks.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use OCP\RichObjectStrings\IRichTextFormatter;
1313
use OCP\SetupCheck\ISetupCheckManager;
14+
use Symfony\Component\Console\Input\InputArgument;
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Output\OutputInterface;
1617

@@ -28,11 +29,41 @@ protected function configure(): void {
2829
$this
2930
->setName('setupchecks')
3031
->setDescription('Run setup checks and output the results')
32+
->addArgument(
33+
'type',
34+
InputArgument::OPTIONAL,
35+
'Category (or class) of setup checks to run ' . "\n" . '(e.g. "network" to run all the network-related checks or "OCA\\Settings\\SetupChecks\\InternetConnectivity" to run only the InternetConnectivity check)',
36+
'all'
37+
)
3138
;
3239
}
3340

3441
protected function execute(InputInterface $input, OutputInterface $output): int {
35-
$results = $this->setupCheckManager->runAll();
42+
$limit = $input->getArgument('type');
43+
44+
if (!is_string($limit)) {
45+
$output->writeln('<error>Invalid type specified</error>');
46+
return self::FAILURE;
47+
}
48+
49+
switch ($limit) {
50+
case 'all': // run all checks (the default)
51+
$results = $this->setupCheckManager->runAll();
52+
break;
53+
54+
default: // limit checks to a specific category or class
55+
if (substr_count($limit, '\\') > 1) {
56+
$results = $this->setupCheckManager->runClass($limit);
57+
} else {
58+
$results = $this->setupCheckManager->runCategory($limit);
59+
}
60+
61+
if (empty($results)) {
62+
$output->writeln('<error>Invalid type specified (or no results for that type)</error>');
63+
return self::FAILURE;
64+
}
65+
}
66+
3667
switch ($input->getOption('output')) {
3768
case self::OUTPUT_FORMAT_JSON:
3869
case self::OUTPUT_FORMAT_JSON_PRETTY:

0 commit comments

Comments
 (0)