From 29b34d7de0ef9b7b640dffe945351dc0147def46 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Wed, 18 Nov 2015 10:40:06 -0800 Subject: [PATCH] Listing all plugins with CLI available. Better helper when empty arguments --- bin/plugin | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/bin/plugin b/bin/plugin index fd68f429a..fd4540569 100755 --- a/bin/plugin +++ b/bin/plugin @@ -63,7 +63,26 @@ $output->getFormatter()->setStyle('red', new OutputFormatterStyle('red', null, a $output->getFormatter()->setStyle('white', new OutputFormatterStyle('white', null, array('bold'))); if (!$name) { - $output->writeln("A Plugin Name (slug format) is required. Example: '{$bin} error log'"); + $output->writeln(''); + $output->writeln("Usage:"); + $output->writeln(" {$bin} [slug] [command] [arguments]"); + $output->writeln(''); + $output->writeln("Example:"); + $output->writeln(" {$bin} error log -l 1 --trace"); + $list = Folder::all('plugins://', ['compare' => 'Pathname', 'pattern' => '/\/cli\/([A-Z][a-z]+Command\.php)$/usm']); + + if (count($list)) { + $available = []; + $output->writeln(''); + $output->writeln('Plugins with CLI available:'); + foreach($list as $index => $entry) { + $split = explode('/', $entry); + $entry = array_shift($split); + $index = str_pad($index++ + 1, 2, '0', STR_PAD_LEFT); + $output->writeln(' ' . $index . ". " . str_pad($entry, 15) . " ${bin} ${entry} list"); + } + } + exit; }