コード例 #1
0
ファイル: Cmd.php プロジェクト: xinc-develop/xinc-server
 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');
 }