public function validateAndExecute($args, $argsIndex, Context $context) { // $argsIndex points to the first of our arguments // ... if it is set at all if (!isset($args[$argsIndex])) { // show the general help, and bail $this->showGeneralHelp($context); return 0; } // if we get here, the user wants detailed help with a // specific command $commandForHelp = $args[$argsIndex]; $se = $context->stderr; // is this a valid command? if (!$context->commandsList->testHasCommand($commandForHelp)) { ErrorsHelper::unknownCommand($context, $commandForHelp); return 1; } // we have a command to show the details of $so = $context->stdout; $command = $context->commandsList->getCommand($commandForHelp); $command->outputHelp($context); return 0; }
protected function validateCommand($argv, $argsIndex, Context $context) { // $argsIndex points to the command that the user // wishes to execute $commandName = $argv[$argsIndex]; // do we have a recognised command? if (!$context->commandsList->testHasCommand($commandName)) { // no, we do not ErrorsHelper::unknownCommand($context, $commandName); return 1; } // if we get here, we know that we have a valid command return null; }