MDL-81949 tool_replace: prompt user for unrecognised CLI parameters.

This commit is contained in:
Paul Holden 2024-05-17 10:51:55 +01:00
parent d3ae1391ab
commit da04fc522a
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164

View File

@ -57,7 +57,13 @@ list($options, $unrecognized) = cli_get_params(
)
);
if ($options['help'] || $options['search'] === null || $options['replace'] === null) {
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
}
// Ensure that user has populated both the search/replace parameters.
if ($options['help'] || !is_string($options['search']) || !is_string($options['replace'])) {
echo $help;
exit(0);
}