unset( $assoc_args['json'] );
}
+ // --{version|info} -> _sys {version|info}
+ if ( empty( $args ) ) {
+ foreach ( array( 'version', 'info' ) as $key ) {
+ if ( isset( $assoc_args[ $key ] ) ) {
+ $args = array( '_sys', $key );
+ break;
+ }
+ }
+ }
+
return array( $args, $assoc_args );
}
$this->init_logger();
- // Handle a bunch of special-purpose flags
- if ( empty( $this->arguments ) ) {
- foreach ( array( 'version', 'info', 'param-dump', 'cmd-dump' ) as $key ) {
- if ( isset( $this->assoc_args[ $key ] ) ) {
- call_user_func( array( '\\WP_CLI\\InternalFlags',
- str_replace( '-', '_', $key ) ) );
- exit;
- }
- }
- }
-
$_SERVER['DOCUMENT_ROOT'] = realpath( $this->config['path'] );
+ if ( $this->cmd_starts_with( array( '_sys' ) ) ) {
+ $this->_run_command();
+ exit;
+ }
+
// First try at showing man page
if ( $this->cmd_starts_with( array( 'help' ) ) ) {
$this->_run_command();
// Handle --completions parameter
if ( isset( $this->assoc_args['completions'] ) ) {
- \WP_CLI\InternalFlags::completions();
+ foreach ( WP_CLI::$root->get_subcommands() as $name => $command ) {
+ $subcommands = Dispatcher\get_subcommands( $command );
+
+ WP_CLI::line( $name . ' ' . implode( ' ', array_keys( $subcommands ) ) );
+ }
exit;
}
<?php
-namespace WP_CLI;
-use \WP_CLI;
+use \WP_CLI\Dispatcher,
+ \WP_CLI\Utils;
-/**
- * Class that handles special assoc parameters
- */
-class InternalFlags {
+class Sys_Command extends WP_CLI_Command {
- static function version() {
- WP_CLI::line( 'wp-cli ' . WP_CLI_VERSION );
- }
-
- static function info() {
- $php_bin = defined( 'PHP_BINARY' ) ? PHP_BINARY : getenv( 'WP_CLI_PHP_USED' );
-
- WP_CLI::line( "PHP binary:\t" . $php_bin );
- WP_CLI::line( "PHP version:\t" . PHP_VERSION );
- WP_CLI::line( "php.ini used:\t" . get_cfg_var( 'cfg_file_path' ) );
- WP_CLI::line( "wp-cli root:\t" . WP_CLI_ROOT );
- WP_CLI::line( "wp-cli config:\t" . WP_CLI::get_config_path() );
- WP_CLI::line( "wp-cli version:\t" . WP_CLI_VERSION );
- }
-
- static function param_dump() {
- echo json_encode( Utils\get_config_spec() );
- }
-
- static function cmd_dump() {
- echo json_encode( self::command_to_array( WP_CLI::$root ) );
- }
-
- private static function command_to_array( $command ) {
+ private function command_to_array( $command ) {
$dump = array(
'name' => $command->get_name(),
'description' => $command->get_shortdesc(),
return $dump;
}
- static function completions() {
- foreach ( WP_CLI::$root->get_subcommands() as $name => $command ) {
- $subcommands = Dispatcher\get_subcommands( $command );
+ function version() {
+ WP_CLI::line( 'wp-cli ' . WP_CLI_VERSION );
+ }
- WP_CLI::line( $name . ' ' . implode( ' ', array_keys( $subcommands ) ) );
- }
+ function info() {
+ $php_bin = defined( 'PHP_BINARY' ) ? PHP_BINARY : getenv( 'WP_CLI_PHP_USED' );
+
+ WP_CLI::line( "PHP binary:\t" . $php_bin );
+ WP_CLI::line( "PHP version:\t" . PHP_VERSION );
+ WP_CLI::line( "php.ini used:\t" . get_cfg_var( 'cfg_file_path' ) );
+ WP_CLI::line( "wp-cli root:\t" . WP_CLI_ROOT );
+ WP_CLI::line( "wp-cli config:\t" . WP_CLI::get_config_path() );
+ WP_CLI::line( "wp-cli version:\t" . WP_CLI_VERSION );
+ }
+
+ /**
+ * @subcommand param-dump
+ */
+ function param_dump() {
+ echo json_encode( Utils\get_config_spec() );
+ }
+
+ /**
+ * @subcommand cmd-dump
+ */
+ function cmd_dump() {
+ echo json_encode( self::command_to_array( WP_CLI::$root ) );
}
}
+WP_CLI::add_command( '_sys', 'Sys_Command' );
+