Exemplo n.º 1
0
 public function getOptionParser()
 {
     $parser = new ConsoleOptionParser($this->name);
     $parser->description(__('RADIUSdesk console for various tasks'));
     $parser->addOption('ping', array('help' => 'Do a ping monitor test', 'boolean' => true));
     $parser->addOption('heartbeat', array('help' => 'Do a heartbeat monitor test', 'boolean' => true));
     $parser->addArgument('action', array('help' => 'The action to do', 'required' => true, 'choices' => array('mon', 'restart_check', 'debug_check', 'auto_close')));
     $parser->epilog('Have alot of fun....');
     return $parser;
 }
 /**
  * Test that a long set of arguments doesn't make useless output.
  *
  * @return void
  */
 public function testHelpWithLotsOfArguments()
 {
     $parser = new ConsoleOptionParser('mycommand', false);
     $parser->addArgument('test', array('help' => 'A test option.'))->addArgument('test2', array('help' => 'A test option.'))->addArgument('test3', array('help' => 'A test option.'))->addArgument('test4', array('help' => 'A test option.'))->addArgument('test5', array('help' => 'A test option.'))->addArgument('test6', array('help' => 'A test option.'))->addArgument('test7', array('help' => 'A test option.'))->addArgument('model', array('help' => 'The model to make.', 'required' => true))->addArgument('other_longer', array('help' => 'Another argument.'));
     $formatter = new HelpFormatter($parser);
     $result = $formatter->text();
     $expected = 'cake mycommand [-h] [arguments]';
     $this->assertContains($expected, $result);
 }
 /**
  * test that arguments with choices enforce them.
  *
  * @expectedException ConsoleException
  * @return void
  */
 public function testPositionalArgWithChoices()
 {
     $parser = new ConsoleOptionParser('test', FALSE);
     $parser->addArgument('name', array('choices' => array('mark', 'jose')))->addArgument('alias', array('choices' => array('cowboy', 'samurai')))->addArgument('weapon', array('choices' => array('gun', 'sword')));
     $result = $parser->parse(array('mark', 'samurai', 'sword'));
     $expected = array('mark', 'samurai', 'sword');
     $this->assertEquals($expected, $result[1], 'Got the correct value.');
     $parser->parse(array('jose', 'coder'));
 }