예제 #1
0
 public function setupGetopt()
 {
     $getopt = new Getopt();
     $getopt->addOptions($this->getCommandlineOptions());
     $getopt->addOptions($this->xinc->getCommandlineOptions());
     $loader = $this->xinc->getConfigLoader();
     $getopt->addOptions($loader->getCommandlineOptions());
     // add more defaults
     $options = $getopt->getOptionObjects();
     $base = $options['working-dir']->getDefaultValue();
     $options['config-dir']->setDefaultValue("{$base}etc/xinc/");
     $options['project-dir']->setDefaultValue($options['config-dir']->getDefaultValue() . Xinc::DEFAULT_PROJECT_DIR . "/");
     return $getopt;
 }
예제 #2
0
 public function testOptionIterator()
 {
     $this->setExpectedException('InvalidArgumentException');
     $getopt = new Getopt(array(array('a', null, Getopt::NO_ARGUMENT), array('b', 'beta', Getopt::REQUIRED_ARGUMENT)));
     $getopt->parse('-a -b foo');
     $expected = array('a' => 1, 'beta' => 'foo');
     // 'b' should not occur
     foreach ($getopt->getIterator('long') as $option => $value) {
         $this->assertEquals($expected[$option], $value->getValue());
     }
     $getopt->getIterator('foo');
 }