diff options
-rw-r--r-- | plugins/CorePluginsAdmin/Commands/ListPlugins.php | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/CorePluginsAdmin/Commands/ListPlugins.php b/plugins/CorePluginsAdmin/Commands/ListPlugins.php index 0fc132e589..aefbe126ed 100644 --- a/plugins/CorePluginsAdmin/Commands/ListPlugins.php +++ b/plugins/CorePluginsAdmin/Commands/ListPlugins.php @@ -12,6 +12,7 @@ use Piwik\Plugin\ConsoleCommand; use Piwik\Plugin\Manager; use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; /** @@ -23,6 +24,7 @@ class ListPlugins extends ConsoleCommand { $this->setName('plugin:list'); $this->setDescription('List installed plugins.'); + $this->addOption('filter-plugin', null, InputOption::VALUE_OPTIONAL, 'If given, prints only plugins that contain this term.'); } protected function execute(InputInterface $input, OutputInterface $output) @@ -31,6 +33,14 @@ class ListPlugins extends ConsoleCommand $plugins = $pluginManager->getInstalledPluginsName(); + $pluginFilter = $input->getOption('filter-plugin'); + + if (!empty($pluginFilter)) { + $plugins = array_filter($plugins, function ($pluginName) use ($pluginFilter) { + return strpos($pluginName, $pluginFilter) !== false; + }); + } + $plugins = array_map(function ($plugin) use ($pluginManager) { return array( '<info>' . $plugin . '</info>', |