public function testGet() { $data = array('foo' => 'bar'); $this->assertEquals('bar', Utils::get($data, 'foo')); $this->assertNull(Utils::get($data, 'unknown')); $this->assertEquals('default', Utils::get($data, 'unknown', 'default')); }
/** * Execute command * * @param array $args * @param array $options */ public function execute(array $args, array $options = array()) { if (empty($args)) { $this->showUsage(); $this->showCommands(); } else { $this->showHelp($args[0], Utils::get($args, 1)); } }
/** * Execute command * * @param array $args * @param array $options */ public function execute(array $args, array $options = array()) { if (!empty($options['version'])) { return $this->showVersion(); } if (empty($args)) { $this->writeln("DBVC - Database version control\n"); $this->showUsage(); $this->showOptions(); $this->showCommands(); } else { $this->showHelp($args[0], Utils::get($args, 1)); } }
public function execute(array $args, array $options = array()) { if (empty($args)) { $formater = new ConsoleKit\TextFormater(array('quote' => ' * ')); $this->writeln('Available commands:', ConsoleKit\Colors::BLACK | ConsoleKit\Colors::BOLD); foreach ($this->console->getCommands() as $name => $fqdn) { if ($fqdn !== __CLASS__) { $this->writeln($formater->format($name)); } } $this->writeln("Use 'clamp help command' for more info"); } else { $commandFQDN = $this->console->getCommand($args[0]); $help = ConsoleKit\Help::fromFQDN($commandFQDN, ConsoleKit\Utils::get($args, 1)); $this->writeln($help); } }
public function execute(array $args, array $options = array()) { $this->context(array('fgcolor' => Utils::get($options, 'color')), function ($c) use($args) { $c->writeln(sprintf('hello %s!', $args[0])); }); }