Use WP_CLI::runcommand() instead, which is easier to use and works better.
Note: While this command does persist a limited set of runtime arguments,
it *does not* persist environment variables. Practically speaking, WP-CLI
packages won't be loaded when using WP_CLI::launch_self() because the
launched process doesn't have access to the current process $HOME.
public static launch_self ( string $command, array $args = [], array $assoc_args = [], boolean $exit_on_error = true, boolean $return_detailed = false, array $runtime_args = [] ) : integer | ProcessRun | ||
$command | string | WP-CLI command to call. |
$args | array | Positional arguments to include when calling the command. |
$assoc_args | array | Associative arguments to include when calling the command. |
$exit_on_error | boolean | Whether to exit if the command returns an elevated return code. |
$return_detailed | boolean | Whether to return an exit status (default) or detailed execution results. |
$runtime_args | array | Override one or more global args (path,url,user,allow-root) |
return | integer | ProcessRun | The command exit status, or a ProcessRun instance |