WP_CLI
Runner::run_command()
Find the WP-CLI command to run given arguments, and invoke it.
Method of the class: Runner{}
No Hooks.
Return
null
. Nothing (null).
Usage
$Runner = new Runner(); $Runner->run_command( $args, $assoc_args, $options );
- $args(array) (required)
- Positional arguments including command name
- $assoc_args(array)
- Associative arguments for the command.
Default: [] - $options(array)
- Configuration options for the function.
Default: []
Runner::run_command() Runner::run command code WP-CLI 2.8.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() ); } }