1111
1212use OCP \RichObjectStrings \IRichTextFormatter ;
1313use OCP \SetupCheck \ISetupCheckManager ;
14+ use Symfony \Component \Console \Input \InputArgument ;
1415use Symfony \Component \Console \Input \InputInterface ;
1516use Symfony \Component \Console \Output \OutputInterface ;
1617
@@ -29,12 +30,44 @@ protected function configure(): void {
2930 $ this
3031 ->setName ('setupchecks ' )
3132 ->setDescription ('Run setup checks and output the results ' )
33+ ->addArgument (
34+ 'category ' ,
35+ InputArgument::OPTIONAL ,
36+ 'Category of setup checks to run ' . "\n" . '(e.g. "network" to run all the network-related checks) ' ,
37+ ''
38+ )
39+ ->addArgument (
40+ 'class ' ,
41+ InputArgument::OPTIONAL ,
42+ 'Class of setup checks to run ' . "\n" . '(e.g. "OCA \\Settings \\SetupChecks \\InternetConnectivity" to run only the InternetConnectivity check) ' ,
43+ ''
44+ )
3245 ;
3346 }
3447
3548 #[\Override]
3649 protected function execute (InputInterface $ input , OutputInterface $ output ): int {
37- $ results = $ this ->setupCheckManager ->runAll ();
50+ $ filterByCategory = $ input ->getArgument ('category ' );
51+ $ filterByClass = $ input ->getArgument ('class ' );
52+
53+ if (!is_string ($ filterByCategory ) || !is_string ($ filterByClass )) {
54+ $ output ->writeln ('<error>Invalid type specified</error> ' );
55+ return self ::FAILURE ;
56+ }
57+
58+ if ($ filterByCategory !== '' && $ filterByClass !== '' ) {
59+ $ output ->writeln ('<error>Please specify only one of category or class</error> ' );
60+ return self ::FAILURE ;
61+ }
62+
63+ if ($ filterByCategory !== '' ) {
64+ $ results = $ this ->setupCheckManager ->runByCategory ($ filterByCategory );
65+ } elseif ($ filterByClass !== '' ) {
66+ $ results = $ this ->setupCheckManager ->runByClass ($ filterByClass );
67+ } else {
68+ $ results = $ this ->setupCheckManager ->runAll ();
69+ }
70+
3871 switch ($ input ->getOption ('output ' )) {
3972 case self ::OUTPUT_FORMAT_JSON :
4073 case self ::OUTPUT_FORMAT_JSON_PRETTY :
0 commit comments