Implement wp site get command to enable site operations by URL#571
Implement wp site get command to enable site operations by URL#571
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
… reliability Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
This comment was marked as resolved.
This comment was marked as resolved.
|
/gemini review |
There was a problem hiding this comment.
Code Review
The implementation of wp site get is a solid addition that fulfills the requirement of fetching site details by URL. The code is well-structured, follows WP-CLI conventions, and includes comprehensive Behat tests. I've suggested a more robust way to detect URLs to support domain-only inputs and ensure a smoother user experience.
|
@copilot increase test coverage also: The current URL detection logic is a bit restrictive as it only recognizes strings containing // Check if the argument is a URL or a domain (non-numeric)
if ( ! is_numeric( $site_arg ) ) {
// Normalize URLs without a scheme for proper parsing.
$url_to_parse = $site_arg;
if ( false === strpos( $url_to_parse, '://' ) ) {
$url_to_parse = 'http://' . $url_to_parse;
} |
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Implemented! Changed URL detection to use
All 32 site.feature scenarios now pass. (47d921e) Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Multisite installations with custom domains couldn't easily delete sites by URL - only by ID or slug, which required manual lookup in automated workflows.
Implementation
Adds
wp site get <site>command that accepts both site IDs and full URLs:URL detection and lookup
is_numeric()to distinguish between site IDs (numeric) and URLs/domains (non-numeric)http://wp_parse_url()to extract domain and pathget_blog_id_from_url()function for efficient lookups2http://example.com/site1/example.com/site1example.comsubdomain.example.comOutput formatting
WP_CLI\Formatterwith standard format optionsblog_id,url,last_updated,registeredsite_id,domain,path,public,archived,mature,spam,deleted,lang_id--fieldparameter for single field extractionCommand registration
composer.jsoncommands listUsage
Test Coverage
Added comprehensive Behat test scenarios covering:
All 32 test scenarios pass (372 steps).
Follows the pattern established by
wp user getandwp post getfor consistency with existing commands.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.