本文整理汇总了PHP中WP_CLI::get_root_command方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_CLI::get_root_command方法的具体用法?PHP WP_CLI::get_root_command怎么用?PHP WP_CLI::get_root_command使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_CLI
的用法示例。
在下文中一共展示了WP_CLI::get_root_command方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: completions
/**
* Generate tab completion strings.
*/
function completions()
{
foreach (WP_CLI::get_root_command()->get_subcommands() as $name => $command) {
$subcommands = $command->get_subcommands();
WP_CLI::line($name . ' ' . implode(' ', array_keys($subcommands)));
}
}
示例2: find_subcommand
private static function find_subcommand($args)
{
$command = \WP_CLI::get_root_command();
while (!empty($args) && $command && $command->can_have_subcommands()) {
$command = $command->find_subcommand($args);
}
return $command;
}
示例3: find_command_to_run
/**
* Given positional arguments, find the command to execute.
*
* @param array $args
* @return array|string Command, args, and path on success; error message on failure
*/
public function find_command_to_run($args)
{
$command = \WP_CLI::get_root_command();
$cmd_path = array();
while (!empty($args) && $command->can_have_subcommands()) {
$cmd_path[] = $args[0];
$full_name = implode(' ', $cmd_path);
$subcommand = $command->find_subcommand($args);
if (!$subcommand) {
return sprintf("'%s' is not a registered wp command. See 'wp help'.", $full_name);
}
if ($this->is_command_disabled($subcommand)) {
return sprintf("The '%s' command has been disabled from the config file.", $full_name);
}
$command = $subcommand;
}
return array($command, $args, $cmd_path);
}
示例4: cmd_dump
/**
* Dump the list of installed commands, as JSON.
*
* @subcommand cmd-dump
*/
public function cmd_dump()
{
echo json_encode(self::command_to_array(WP_CLI::get_root_command()));
}