Skip to content

Commit 94aae2f

Browse files
committed
Extend cli/crawler.php to let the admin set the verbosity level
1 parent c6d37db commit 94aae2f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

cli/crawler.php

+24-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,28 @@
2929
require_once($CFG->libdir.'/clilib.php');
3030
require_once($CFG->dirroot .'/admin/tool/crawler/lib.php');
3131

32-
tool_crawler_crawl(1);
32+
list($options, $unrecognized) = cli_get_params(array(
33+
'help' => false,
34+
'verbose' => 1,
35+
),
36+
array(
37+
'h' => 'help'
38+
));
39+
40+
if ($unrecognized) {
41+
$unrecognized = implode("\n ", $unrecognized);
42+
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
43+
}
44+
45+
if ($options['help']) {
46+
echo get_string('clicrawlerhelp', 'tool_crawler');
47+
die();
48+
}
49+
50+
if ($options['verbose'] && (!is_numeric($options['verbose']) || $options['verbose'] < 0 || $options['verbose'] > 2)) {
51+
echo get_string('clicrawlerhelp', 'tool_crawler');
52+
die();
53+
}
54+
55+
tool_crawler_crawl($options['verbose']);
3356

lang/en/tool_crawler.php

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@
4949
Example:
5050
$sudo -u www-data php crawl-as.php --url=https://host.example/
5151
';
52+
$string['clicrawlerhelp'] = 'Run the crawler manually without having to wait for the scheduled task.
53+
54+
Options:
55+
-h, --help Print out this help
56+
--verbose=<level> Verbosity level (0 = Quiet, 1 = Standard verbosity, 2 = Extended verbosity), Default: 1
57+
58+
Example:
59+
$sudo -u www-data php crawler.php --verbose=1
60+
';
5261
$string['clierror'] = 'Error: {$a}';
5362
$string['cliscrapeashelp'] = 'Scrape the URL as the robot would see it, but do not process/queue it.
5463

0 commit comments

Comments
 (0)