Yaffs site version 1.1
[yaffs-website] / vendor / psy / psysh / src / Psy / Command / ListCommand.php
index e463366b67da363ba39be0ddeff87cbdf5b39e3e..cd38eb59d6f6f0c7391fd899cee26a5d030120b3 100644 (file)
@@ -22,6 +22,7 @@ use Psy\Command\ListCommand\PropertyEnumerator;
 use Psy\Command\ListCommand\TraitEnumerator;
 use Psy\Command\ListCommand\VariableEnumerator;
 use Psy\Exception\RuntimeException;
+use Psy\Input\FilterOptions;
 use Psy\VarDumper\Presenter;
 use Psy\VarDumper\PresenterAware;
 use Symfony\Component\Console\Formatter\OutputFormatter;
@@ -54,6 +55,8 @@ class ListCommand extends ReflectingCommand implements PresenterAware
      */
     protected function configure()
     {
+        list($grep, $insensitive, $invert) = FilterOptions::getOptions();
+
         $this
             ->setName('ls')
             ->setAliases(array('list', 'dir'))
@@ -72,9 +75,9 @@ class ListCommand extends ReflectingCommand implements PresenterAware
                 new InputOption('properties',  'p', InputOption::VALUE_NONE,     'Display class or object properties (public properties by default).'),
                 new InputOption('methods',     'm', InputOption::VALUE_NONE,     'Display class or object methods (public methods by default).'),
 
-                new InputOption('grep',        'G', InputOption::VALUE_REQUIRED, 'Limit to items matching the given pattern (string or regex).'),
-                new InputOption('insensitive', 'i', InputOption::VALUE_NONE,     'Case-insensitive search (requires --grep).'),
-                new InputOption('invert',      'v', InputOption::VALUE_NONE,     'Inverted search (requires --grep).'),
+                $grep,
+                $insensitive,
+                $invert,
 
                 new InputOption('globals',     'g', InputOption::VALUE_NONE,     'Include global variables.'),
                 new InputOption('internal',    'n', InputOption::VALUE_NONE,     'Limit to internal functions and classes.'),
@@ -123,7 +126,7 @@ HELP
             $reflector = null;
         }
 
-        // TODO: something cleaner than this :-/
+        // @todo something cleaner than this :-/
         if ($input->getOption('long')) {
             $output->startPaging();
         }
@@ -237,15 +240,6 @@ HELP
      */
     private function validateInput(InputInterface $input)
     {
-        // grep, invert and insensitive
-        if (!$input->getOption('grep')) {
-            foreach (array('invert', 'insensitive') as $option) {
-                if ($input->getOption($option)) {
-                    throw new RuntimeException('--' . $option . ' does not make sense without --grep');
-                }
-            }
-        }
-
         if (!$input->getArgument('target')) {
             // if no target is passed, there can be no properties or methods
             foreach (array('properties', 'methods', 'no-inherit') as $option) {