Add --slug=<site> as an available parameter to wp site commands - #416
Conversation
|
Great work so far, @tubiz ! Are you still up for adding feature tests for this? |
Yes. I will get started with adding the feature tests. |
danielbachhuber
left a comment
There was a problem hiding this comment.
Can we include some tests covering this change? Also, it'd be great to abstract the site fetcher to a dedicated method.
danielbachhuber
left a comment
There was a problem hiding this comment.
Getting better! I think there's just one last bit to address.
| $this->update_site_status( [ $blog->blog_id ], 'archived', 1 ); | ||
| } else { | ||
| $this->update_site_status( $args, 'archived', 1 ); | ||
| } |
There was a problem hiding this comment.
For all of these, we also need to provide some error mechanism when neither <id> nor --slug= are provided. Check out wp plugin activate and its sibling commands for an example of how this can be implemented:
https://github.com/wp-cli/extension-command/blob/6a68d247969b8968b007a4d664e0de14bf69e775/src/Plugin_Command.php#L317-L320
https://github.com/wp-cli/extension-command/blob/6a68d247969b8968b007a4d664e0de14bf69e775/src/WP_CLI/ParsePluginNameInput.php#L9-L47
We'll want to add tests for this aspect too.
Your get_site_by_slug() method could be updated to $this->get_sites( $args, $assoc_args ) and return a $blogs variable that's passed directly into $this->update_site_status()
There was a problem hiding this comment.
Update get_site_by_slug() method to get_sites_ids()
The check to ensure that the site IDs or slug are provided is now done in the check_site_ids_and_slug() method.
Fixes #257
Slug has been added as an available parameter for the wp site commands listed below
wp site archive --slug={siteslug}wp site activate --slug={siteslug}wp site deactivate --slug={siteslug}wp site mature --slug={siteslug}wp site private --slug={siteslug}wp site public --slug={siteslug}wp site spam --slug={siteslug}wp site unarchive --slug={siteslug}wp site unmature --slug={siteslug}wp site unspam --slug={siteslug}Related wp-cli/wp-cli#5832