Beispiel #1
0
 /**
  *  (experimental)
  *  @return array
  */
 private function _getPearOpt(&$cmd_obj, $cmd_str, $opt_array)
 {
     $short_args = $long_args = null;
     PEAR_Command::getGetOptArgs($cmd_str, $short_args, $long_args);
     $opt = new Ethna_Getopt();
     $opt_arg = $opt->getopt($opt_array, $short_args, $long_args);
     if (Ethna::isError($opt_arg)) {
         return array();
     }
     $opts = array();
     foreach ($opt_arg[0] as $tmp) {
         list($opt, $val) = $tmp;
         if ($val === null) {
             $val = true;
         }
         if (strlen($opt) == 1) {
             $cmd_opts = $cmd_obj->getOptions($cmd_str);
             foreach ($cmd_opts as $o => $d) {
                 if (isset($d['shortopt']) && $d['shortopt'] == $opt) {
                     $opts[$o] = $val;
                 }
             }
         } else {
             if (substr($opt, 0, 2) == '--') {
                 $opts[substr($opt, 2)] = $val;
             }
         }
     }
     return $opts;
 }