Example #1
0
 /**
  * Gets the basic descriptions of a command's paramters and options from docs
  *
  * @param CompositeCommand $command The command of which to get options
  * @return array
  */
 private function getOptions(CompositeCommand $command)
 {
     $longdesc = $command->getLongdesc();
     $synopses = explode(' ', str_replace(array('[', ']'), '', $command->getSynopsis()));
     $options = array();
     if (is_string($longdesc)) {
         $options_list = explode("\n\n", $longdesc);
         foreach ($options_list as $option) {
             $drilldown = explode("\n", $option);
             $key = str_replace(array('[', ']'), '', $drilldown[0]);
             if (!in_array($key, $synopses)) {
                 continue;
             }
             $value = str_replace(array(': ', "\n"), array('', ' '), $drilldown[1]);
             $options[$key] = $value;
         }
     } elseif (isset($longdesc['parameters'])) {
         foreach ($longdesc['parameters'] as $parameter) {
             $options[$parameter['synopsis']] = $parameter['desc'];
         }
     }
     if (empty($options)) {
         return false;
     }
     return $options;
 }