printHelp() публичный метод

Print the help
public printHelp ( )
Пример #1
0
     */
    public function printHelp()
    {
        echo "\nThis CLI tool supports the following options:\n\n";
        foreach ($this->getOptions() as $option => $value) {
            echo "For {$option} use -{$value['short']} or --{$value['long']}\n";
        }
        echo "\nThis CLI tool supports the following commands:\n\n";
        foreach ($this->getCommands() as $endpoint => $commands) {
            echo "This CLI supports the {$endpoint} endpoint with the following commands: " . implode(", ", array_keys($commands)) . "\n";
        }
    }
}
// Include the DataSift library
require dirname(__FILE__) . '/datasift.php';
try {
    $cli = new Cli($argv);
    $commands = $cli->getCommands();
    $parsedOptions = $cli->parseInput();
    $cli->validateCommands($parsedOptions);
    //Create Datasift user
    $user = new DataSift_User($parsedOptions['authenticate']['username'], $parsedOptions['authenticate']['api_key'], $parsedOptions['ssl'], true, $parsedOptions['url']);
    $object = $cli->getEndPointObject($parsedOptions['endpoint'], $user);
    $command_parameters = $cli->getCallParameters($commands[$parsedOptions['endpoint']][$parsedOptions['command']], $parsedOptions['parameters'], $user);
    //Output the last response
    print_r($cli->callCommand($object, $parsedOptions['command'], $command_parameters, $user, $parsedOptions['pretty']));
    echo "\n";
} catch (Exception $e) {
    echo get_class($e) . ": " . $e->getMessage() . "\n";
    $cli->printHelp();
}