Better error checking in bin/plugin for existence and enabled

This commit is contained in:
Andy Miller
2019-03-05 12:46:48 -07:00
parent 5008672a48
commit 1c725c02f0
2 changed files with 15 additions and 1 deletions

View File

@@ -10,6 +10,7 @@
* Improved `File::save()` to use a temporary file if file isn't locked
* Improved `|t` filter to better support admin `|tu` style filter if in admin
* Update all classes to rely on `PageInterface` instead of `Page` class
* Better error checking in `bin/plugin` for existence and enabled
1. [](#bugfix)
* Grav 1.6: Fixed `FlexUser` loosing ACL information
* Grav 1.6: Fixed `FlexUser::find()` breaking when nothing is found

View File

@@ -58,7 +58,6 @@ $grav['users'];
$grav['plugins']->init();
$grav['themes']->init();
$app = new Application('Grav Plugins Commands', GRAV_VERSION);
$pattern = '([A-Z]\w+Command\.php)';
@@ -73,12 +72,26 @@ $argv = array_merge([$bin], $argv);
$input = new ArgvInput($argv);
/** @var \Grav\Common\Data\Data $plugin */
$plugin = $grav['plugins']->get($name);
$output = new ConsoleOutput();
$output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, array('bold')));
$output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, array('bold')));
if (is_null($plugin)) {
$output->writeln('');
$output->writeln("<red>$name plugin not found</red>");
die;
}
if (!$plugin->enabled) {
$output->writeln('');
$output->writeln("<red>$name not enabled</red>");
die;
}
if (!$name) {
$output->writeln('');
$output->writeln('<red>Usage:</red>');