Beispiel #1
0
 private function init($args, UserInterface $ui)
 {
     $flags = new Flags();
     $displayHelp =& $flags->bool('help', false, 'Display this help message.');
     $displayVersion =& $flags->bool('version', false, 'Display this applications version.');
     try {
         $flags->parse($args);
     } catch (\Exception $e) {
         $ui->dropError($e->getMessage(), 1, $flags->getDefaults());
         drop($e->getMessage(), 1, $flags->getDefaults());
     }
     switch (true) {
         case $displayVersion:
             self::versionMarker($ui);
             die(0);
             break;
         case $displayHelp:
         case count($flags->args()) > 1:
             $ui->dumpOptions($flags->getDefaults());
             die(1);
             break;
     }
     return $flags->args() ? current($flags->args()) : self::CONFIG_FILE;
 }
Beispiel #2
0
 function testNotParseExceptionMissingFlagParamException2()
 {
     $flags = new Flags();
     $flags->bool('foo');
     $flags->bool('bar');
     $flags->parse(explode(' ', 'test.php --foo'), true);
 }