WP_CLI
Runner::run_command
Find the WP-CLI command to run given arguments, and invoke it.
Метод класса: Runner{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Runner = new Runner(); $Runner->run_command( $args, $assoc_args, $options );
- $args(массив) (обязательный)
- Positional arguments including command name.
- $assoc_args(массив)
- Associative arguments for the command.
По умолчанию: [] - $options(массив)
- Configuration options for the function.
По умолчанию: []
Код Runner::run_command() Runner::run command WP-CLI 2.13.0-alpha
public function run_command( $args, $assoc_args = [], $options = [] ) {
WP_CLI::do_hook( 'before_run_command', $args, $assoc_args, $options );
if ( ! empty( $options['back_compat_conversions'] ) ) {
list( $args, $assoc_args ) = self::back_compat_conversions( $args, $assoc_args );
}
$r = $this->find_command_to_run( $args );
if ( is_string( $r ) ) {
WP_CLI::error( $r );
}
list( $command, $final_args, $cmd_path ) = $r;
$name = implode( ' ', $cmd_path );
$extra_args = [];
if ( isset( $this->extra_config[ $name ] ) ) {
$extra_args = $this->extra_config[ $name ];
}
WP_CLI::debug( 'Running command: ' . $name, 'bootstrap' );
try {
$command->invoke( $final_args, $assoc_args, $extra_args );
} catch ( Exception $e ) {
WP_CLI::error( $e->getMessage() );
}
}