Airship\Hangar\Commands\Help::fire PHP Method

fire() public method

Execute the help command
public fire ( array $args = [] ) : boolean
$args array - CLI arguments
return boolean
    public function fire(array $args = []) : bool
    {
        $command = !empty($args[0]) ? $args[0] : null;
        if (!empty($command)) {
            if (empty($this->commands[$command])) {
                throw new \Error('Command ' . $command . ' not found!');
            }
            $com = $this->getCommandObject($this->commands[$command]);
            $com->usageInfo($args);
            echo $this->c[''];
            return true;
        }
        $this->usageInfo($args);
        $w = $this->getScreenSize()['width'];
        echo "\n", str_repeat('_', $w - 1), "\n", $this->c[''];
        return true;
    }

Usage Example

Example #1
0
    // 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);