本文整理汇总了PHP中Cli::callCommand方法的典型用法代码示例。如果您正苦于以下问题:PHP Cli::callCommand方法的具体用法?PHP Cli::callCommand怎么用?PHP Cli::callCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cli
的用法示例。
在下文中一共展示了Cli::callCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printHelp
*/
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();
}