PHP Class CLI_Command, wp-cli

Inheritance: extends Terminus_Command
Show file Open project: wp-cli/wp-cli

Public Methods

Method Description
alias ( $_, $assoc_args ) List available WP-CLI aliases.
check_update ( $_, $assoc_args ) Check to see if there is a newer version of WP-CLI available.
cmd_dump ( ) Dump the list of installed commands, as JSON.
completions ( $_, $assoc_args ) Generate tab completion strings.
info ( $_, $assoc_args ) Print various details about the WP-CLI environment.
param_dump ( $_, $assoc_args ) Dump the list of global parameters, as JSON or in var_export format.
update ( $_, $assoc_args ) Update WP-CLI to the latest release.
version ( ) Print WP-CLI version.

Private Methods

Method Description
command_to_array ( $command )
get_update_type_str ( $assoc_args ) Get a string representing the type of update being checked for.
get_updates ( $assoc_args ) Returns update information.

Method Details

alias() public method

Aliases are shorthand references to WordPress installs. For instance, @dev could refer to a development install and @prod could refer to a production install. This command gives you visibility in what registered aliases you have available. ## OPTIONS [--format=] : Render output in a particular format. --- default: yaml options: - yaml - json --- ## EXAMPLES # List all available aliases. $ wp cli alias ---
public alias ( $_, $assoc_args )

check_update() public method

Queries the Github releases API. Returns available versions if there are updates available, or success message if using the latest release. ## OPTIONS [--patch] : Only list patch updates. [--minor] : Only list minor updates. [--major] : Only list major updates. [--field=] : Prints the value of a single field for each update. [--fields=] : Limit the output to specific object fields. Defaults to version,update_type,package_url. [--format=] : Render output in a particular format. --- default: table options: - table - csv - json - count - yaml --- ## EXAMPLES # Check for update. $ wp cli check-update Success: WP-CLI is at the latest version. # Check for update and new version is available. $ wp cli check-update +---------+-------------+-------------------------------------------------------------------------------+ | version | update_type | package_url | +---------+-------------+-------------------------------------------------------------------------------+ | 0.24.1 | patch | https://github.com/wp-cli/wp-cli/releases/download/v0.24.1/wp-cli-0.24.1.phar | +---------+-------------+-------------------------------------------------------------------------------+
public check_update ( $_, $assoc_args )

cmd_dump() public method

## EXAMPLES # Dump the list of installed commands. $ wp cli cmd-dump {"name":"wp","description":"Manage WordPress through the command-line.","longdesc":"\n\n## GLOBAL PARAMETERS\n\n --path=\n Path to the WordPress files.\n\n --ssh=\n Perform operation against a remote server over SSH.\n\n --url=\n Pretend request came from given URL. In multisite, this argument is how the target site is specified. \n\n --user=\n
public cmd_dump ( )

completions() public method

## OPTIONS --line= : The current command line to be executed. --point= : The index to the current cursor position relative to the beginning of the command. ## EXAMPLES # Generate tab completion strings. $ wp cli completions --line='wp eva' --point=100 eval eval-file
public completions ( $_, $assoc_args )

info() public method

Helpful for diagnostic purposes, this command shares: * PHP binary used. * PHP binary version. * php.ini configuration file used (which is typically different than web). * WP-CLI root dir: where WP-CLI is installed (if non-Phar install). * WP-CLI global config: where the global config YAML file is located. * WP-CLI project config: where the project config YAML file is located. * WP-CLI version: currently installed version. See config docs for more details on global and project config YAML files. ## OPTIONS [--format=] : Render output in a particular format. --- default: list options: - list - json --- ## EXAMPLES # Display various data about the CLI environment. $ wp cli info PHP binary: /usr/bin/php5 PHP version: 5.5.9-1ubuntu4.16 php.ini used: /etc/php5/cli/php.ini WP-CLI root dir: phar://wp-cli.phar WP-CLI packages dir: /home/person/.wp-cli/packages/ WP-CLI global config: WP-CLI project config: WP-CLI version: 0.24.1
public info ( $_, $assoc_args )

param_dump() public method

## OPTIONS [--with-values] : Display current values also. [--format=] : Render output in a particular format. --- default: json options: - var_export - json --- ## EXAMPLES # Dump the list of global parameters. $ wp cli param-dump --format=var_export array ( 'path' => array ( 'runtime' => '=', 'file' => '', 'synopsis' => '', 'default' => NULL, 'multiple' => false, 'desc' => 'Path to the WordPress files.', ), 'url' => array (
public param_dump ( $_, $assoc_args )

update() public method

Default behavior is to check the releases API for the newest stable version, and prompt if one is available. Use --stable to install or reinstall the latest stable version. Use --nightly to install the latest built version of the master branch. While not recommended for production, nightly contains the latest and greatest, and should be stable enough for development and staging environments. Only works for the Phar installation mechanism. ## OPTIONS [--patch] : Only perform patch updates. [--minor] : Only perform minor updates. [--major] : Only perform major updates. [--stable] : Update to the latest stable release. Skips update check. [--nightly] : Update to the latest built version of the master branch. Potentially unstable. [--yes] : Do not prompt for confirmation. ## EXAMPLES # Update CLI. $ wp cli update You have version 0.24.0. Would you like to update to 0.24.1? [y/n] y Downloading from https://github.com/wp-cli/wp-cli/releases/download/v0.24.1/wp-cli-0.24.1.phar... New version works. Proceeding to replace. Success: Updated WP-CLI to 0.24.1.
public update ( $_, $assoc_args )

version() public method

## EXAMPLES # Display CLI version. $ wp cli version WP-CLI 0.24.1
public version ( )