public function addCommand(nbCommand $command) { if ($this->hasCommand($command->getFullName(), false)) { throw new InvalidArgumentException(sprintf("[nbCommandSet::addCommand] Command %s already exists", $command->getFullName())); } $this->commands[$command->getFullName()] = $command; }
public function formatHelp(nbCommand $command) { $max = 0; foreach ($command->getArgumentsArray() as $argument) { $length = strlen($argument->getName()) + 2; if ($max < $length) { $max = $length; } } foreach ($command->getOptionsArray() as $option) { $length = strlen($option->getName()) + 6; if ($max < $length) { $max = $length; } } $res = nbHelpFormatter::formatSynopsys($command->getSynopsys()); $res .= nbHelpFormatter::formatArguments($command->getArguments(), $max); $res .= nbHelpFormatter::formatOptions($command->getOptions(), $max - 6); $res .= nbHelpFormatter::formatDescription($command->getDescription()); return $res; }
protected function executeCommand(nbCommand $command, $commandLine, $doit, $verbose) { if ($doit) { $parser = new nbCommandLineParser(); $parser->setDefaultConfigurationDirs($this->getParser()->getDefaultConfigurationDirs()); $command->run($parser, $commandLine); } if ($verbose) { $this->logLine(sprintf("%s %s\n", $command->getFullName(), $commandLine), nbLogger::COMMENT); } }
public function addCommand(nbCommand $command) { $this->commands[] = $command; $briefDescription = $this->getBriefDescription() . ' -> ' . $command->getFullName(); $this->setBriefDescription($briefDescription); }