CLI_Alias_Command::update()publicWP-CLI 1.0

Updates an alias.

OPTIONS

<key>
Key for the alias.
[--set-user=<user>]
Set user for alias.
[--set-url=<url>]
Set url for alias.
[--set-path=<path>]
Set path for alias.
[--set-ssh=<ssh>]
Set ssh for alias.
[--set-http=<http>]
Set http for alias.
[--grouping=<grouping>]
For grouping multiple aliases.
[--config=<config>]
Config file to be considered for operations.
--- options:
  • global
  • project

EXAMPLES

# Update alias.
$ wp cli alias update @prod --set-user=newuser --set-path=/new/path/to/wordpress/install/
Success: Updated 'prod' alias.
# Update project alias.
$ wp cli alias update @prod --set-user=newuser --set-path=/new/path/to/wordpress/install/ --config=project
Success: Updated 'prod' alias.

Method of the class: CLI_Alias_Command{}

No Hooks.

Return

null. Nothing (null).

Usage

$CLI_Alias_Command = new CLI_Alias_Command();
$CLI_Alias_Command->update( $args, $assoc_args );
$args (required)
-
$assoc_args (required)
-

CLI_Alias_Command::update() code WP-CLI 2.8.0-alpha

public function update( $args, $assoc_args ) {

	$config   = ( ! empty( $assoc_args['config'] ) ? $assoc_args['config'] : '' );
	$alias    = $args[0];
	$grouping = Utils\get_flag_value( $assoc_args, 'grouping' );

	list( $config_path, $aliases ) = $this->get_aliases_data( $config, $alias, true );

	$this->validate_config_file( $config_path );

	$this->validate_input( $assoc_args, $grouping );

	if ( empty( $aliases[ $alias ] ) ) {
		WP_CLI::error( "No alias found with key '{$alias}'." );
	}

	if ( null === $grouping ) {
		$aliases = $this->build_aliases( $aliases, $alias, $assoc_args, false, '', true );
	} else {
		$aliases = $this->build_aliases( $aliases, $alias, $assoc_args, true, $grouping, true );
	}

	$this->process_aliases( $aliases, $alias, $config_path, 'Updated' );
}