Skip to content

Commit

Permalink
CLI: Output site URL with some commands. (#8223)
Browse files Browse the repository at this point in the history
Users running a multisite or scripting tools to run multiple single instances might be running Jetpack CLI commands across multiple sites at once. The lack of any information about what site the command is running on diminishes the usefulness of the output.

This change ensures the site URL is printed along with the output so that it's clear which site the command is running against.
  • Loading branch information
philipjohn authored and oskosk committed Nov 28, 2017
1 parent 5a5f2c7 commit e5fd42f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions class.jetpack-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class Jetpack_CLI extends WP_CLI_Command {
*
*/
public function status( $args, $assoc_args ) {

WP_CLI::line( sprintf( __( 'Checking status for %s', 'jetpack' ), esc_url( get_site_url() ) ) );

if ( ! Jetpack::is_active() ) {
WP_CLI::error( __( 'Jetpack is not currently connected to WordPress.com', 'jetpack' ) );
}
Expand Down Expand Up @@ -103,6 +106,9 @@ public function status( $args, $assoc_args ) {
* @subcommand test-connection
*/
public function test_connection( $args, $assoc_args ) {

WP_CLI::line( sprintf( __( 'Testing connection for %s', 'jetpack' ), esc_url( get_site_url() ) ) );

if ( ! Jetpack::is_active() ) {
WP_CLI::error( __( 'Jetpack is not currently connected to WordPress.com', 'jetpack' ) );
}
Expand Down Expand Up @@ -191,7 +197,10 @@ public function disconnect( $args, $assoc_args ) {
case 'blog':
Jetpack::log( 'disconnect' );
Jetpack::disconnect();
WP_CLI::success( __( 'Jetpack has been successfully disconnected.', 'jetpack' ) );
WP_CLI::success( sprintf(
__( 'Jetpack has been successfully disconnected for %s.', 'jetpack' ),
esc_url( get_site_url() )
) );
break;
case 'user':
if ( Jetpack::unlink_user( $user->ID ) ) {
Expand Down Expand Up @@ -244,7 +253,10 @@ public function reset( $args, $assoc_args ) {
$options_to_reset = Jetpack_Options::get_options_for_reset();

// Reset the Jetpack options
_e( "Resetting Jetpack Options...\n", "jetpack" );
WP_CLI::line( sprintf(
__( "Resetting Jetpack Options for %s...\n", "jetpack" ),
esc_url( get_site_url() )
) );
sleep(1); // Take a breath
foreach ( $options_to_reset['jp_options'] as $option_to_reset ) {
Jetpack_Options::delete_option( $option_to_reset );
Expand All @@ -254,7 +266,7 @@ public function reset( $args, $assoc_args ) {
}

// Reset the WP options
_e( "Resetting the jetpack options stored in wp_options...\n", "jetpack" );
WP_CLI::line( __( "Resetting the jetpack options stored in wp_options...\n", "jetpack" ) );
usleep( 500000 ); // Take a breath
foreach ( $options_to_reset['wp_options'] as $option_to_reset ) {
delete_option( $option_to_reset );
Expand All @@ -264,7 +276,7 @@ public function reset( $args, $assoc_args ) {
}

// Reset to default modules
_e( "Resetting default modules...\n", "jetpack" );
WP_CLI::line( __( "Resetting default modules...\n", "jetpack" ) );
usleep( 500000 ); // Take a breath
$default_modules = Jetpack::get_default_modules();
Jetpack::update_active_modules( $default_modules );
Expand Down

0 comments on commit e5fd42f

Please sign in to comment.