class WP_CLI {
private static $configurator;
- public static $runner;
private static $logger;
self::add_man_dir( null, WP_CLI_ROOT . "/man-src" );
self::$configurator = new WP_CLI\Configurator( WP_CLI_ROOT . '/php/config-spec.php' );
- self::$runner = new WP_CLI\Runner;
}
/**
return self::$configurator;
}
+ static function get_root_command() {
+ static $root;
+
+ if ( !$root ) {
+ $root = new Dispatcher\RootCommand;
+ }
+
+ return $root;
+ }
+
static function get_runner() {
- return self::$runner;
+ static $runner;
+
+ if ( !$runner ) {
+ $runner = new WP_CLI\Runner;
+ }
+
+ return $runner;
}
static function colorize( $string ) {
- return \cli\Colors::colorize( $string, self::$runner->in_color() );
+ return \cli\Colors::colorize( $string, self::get_runner()->in_color() );
}
/**
self::get_root_command()->add_subcommand( $name, $command );
}
- static function get_root_command() {
- static $root;
-
- if ( !$root ) {
- $root = new Dispatcher\RootCommand;
- }
-
- return $root;
- }
-
static function add_man_dir( $deprecated = null, $src_dir ) {
self::$man_dirs[] = $src_dir;
}
* @param string $label
*/
static function error( $message, $label = 'Error' ) {
- if ( ! isset( self::$runner->assoc_args[ 'completions' ] ) ) {
+ if ( ! isset( self::get_runner()->assoc_args[ 'completions' ] ) ) {
self::$logger->error( self::error_to_string( $message ), $label );
}
}
static function get_config_path() {
- return self::$runner->config_path;
+ return self::get_runner()->config_path;
}
static function get_config( $key = null ) {
- if ( null === $key )
- return self::$runner->config;
+ if ( null === $key ) {
+ return self::get_runner()->config;
+ }
- if ( !isset( self::$runner->config[ $key ] ) ) {
+ if ( !isset( self::get_runner()->config[ $key ] ) ) {
self::warning( "Unknown config option '$key'." );
return null;
}
- return self::$runner->config[ $key ];
+ return self::get_runner()->config[ $key ];
}
private static function find_command_to_run( $args ) {