示例#1
0
 public function testShouldReturnOptionValueWithOneValue()
 {
     $argumentValue = 'test';
     $parser = new CliParser();
     $parser->setOptions(array('-l' => 'alpha'));
     $parser->setInput('-l ' . $argumentValue);
     $this->assertEquals($argumentValue, $parser->value('-l'));
 }
示例#2
0
 public function run()
 {
     $command = $this->cli->getCommand();
     $className = "DBtrack\\Commands\\{$command}";
     if (!class_exists($className)) {
         throw new \Exception('Invalid command: ' . $command);
     }
     $command = new $className($this->cli->getOptions());
     $command->execute();
 }
示例#3
0
 /**
  *
  */
 public function testParse()
 {
     $arr = array('-a', '-b=foo', '-c', 'bar', '--export', '--foo=bar', '-xyz', '-=asd', 'bluff', 'inva--lid', '--test', 'value', '-q', 'woho');
     $this->object->parse($arr);
     $this->assertTrue($this->object->getValue('-a'));
     $this->assertEquals('foo', $this->object->getValue('-b'));
     $this->assertEquals('bar', $this->object->getValue('-c'));
     $this->assertTrue($this->object->getValue('--export'));
     $this->assertEquals('bar', $this->object->getValue('--foo'));
     $this->assertTrue($this->object->getValue('-x'));
     $this->assertTrue($this->object->getValue('-y'));
     $this->assertTrue($this->object->getValue('-z'));
 }
示例#4
0
 /**
  * Overrides base class, takes aliases into account
  *
  * @param string $flag
  *
  * @return string|bool Returns the value of the flag, string or bool according to the flag
  */
 public function getValue($flag)
 {
     $f = $this->getFlag($flag);
     if ($f) {
         if (array_key_exists($flag, $this->flags)) {
             return parent::getValue($f->getName());
         }
     }
     return false;
 }