diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b70ee4a7..86939c616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/bin/plugin b/bin/plugin index a64ff8990..6f8466d81 100755 --- a/bin/plugin +++ b/bin/plugin @@ -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("$name plugin not found"); + die; +} + +if (!$plugin->enabled) { + $output->writeln(''); + $output->writeln("$name not enabled"); + die; +} + + if (!$name) { $output->writeln(''); $output->writeln('Usage:');