public function test_ParseSpecTextLines()
    {
        $text = <<<EOT
        -i <id> specify an id (required)
        -l, --list operate in list mode
EOT;
        $this->assertEquals(array(array('short' => 'i', 'long' => false, 'value_name' => 'id', 'help' => 'specify an id', 'required' => true), array('short' => 'l', 'long' => 'list', 'value_name' => false, 'help' => 'operate in list mode', 'required' => false)), iterator_to_array(TextSpecParser::createArgumentsSpec($text)));
    }
示例#2
0
 /**
  * create a new CLIOpts parser from a text specification
  *
  * @param string $arguments_spec_text a text specification of expected arguments and options
  *
  * @see TextSpecParser
  * @return CLIOpts a CLIOpts parser.
  */
 public static function createFromTextSpec($arguments_spec_text)
 {
     return new self(TextSpecParser::createArgumentsSpec($arguments_spec_text));
 }
示例#3
0
 protected function verifyParsedArgs($text_spec, $fake_argv, $expected_result)
 {
     $arguments_spec = TextSpecParser::createArgumentsSpec($text_spec);
     $parsed_args = ArgumentsParser::parseArgvWithSpec($fake_argv, $arguments_spec);
     $this->assertEquals($expected_result, $parsed_args);
 }