Beispiel #1
0
 /**
  * Check if the defined argument matches the command argument.
  *
  * @param Argument $argument
  * @param string $command_argument
  *
  * @return bool
  */
 protected function isArgument($argument, $command_argument)
 {
     $possibilities = [$argument->prefix() => "-{$argument->prefix()}", $argument->longPrefix() => "--{$argument->longPrefix()}"];
     foreach ($possibilities as $key => $search) {
         if ($key && strpos($command_argument, $search) === 0) {
             return true;
         }
     }
     return false;
 }
Beispiel #2
0
 /**
  * Builds the summary for any prefixed arguments
  *
  * @param Argument $argument
  *
  * @return string
  */
 protected function prefixedArguments(Argument $argument)
 {
     $prefixes = [$argument->prefix(), $argument->longPrefix()];
     $summary = [];
     foreach ($prefixes as $key => $prefix) {
         if (!$prefix) {
             continue;
         }
         $sub = str_repeat('-', $key + 1) . $prefix;
         if (!$argument->noValue()) {
             $sub .= " {$argument->name()}";
         }
         $summary[] = $sub;
     }
     return implode(', ', $summary);
 }