// Append to $commands array $commands[$index] = $className; if ($argv[1] !== 'help') { // If this is the command the user passed... if ($index === $argv[1]) { // Instantiate this object $exec = Command::getCommandStatic($className); // Store the relevant storage devices in the command, in case they're needed $exec->storeConfig($config); // Execute it, passing the extra parameters to the command's fire() method try { $exec->fire(\array_values(\array_slice($argv, 2))); } catch (\Exception $e) { echo $e->getMessage(), "\n"; $code = $e->getCode(); exit($code > 0 ? $code : 255); } $exec->saveConfig(); exit(0); } } } /** * 4. If all else fails, fall back to the help class... */ $help = new Help($commands); $help->showAll = $showAll; $help->storeConfig($config); $help->fire(\array_values(\array_slice($argv, 2))); $help->saveConfig(); exit(0);