Skip to content

Provide an easier way to specify target site (--url) #5256

@iandunn

Description

@iandunn

My use case / problem

I frequently run commands on a Multisite instance with a large number of sites, most of which have long domains. Typing in the full URL to specify the target site feels unnecessarily tedious and slow.

e.g., wp shell --url=https://2019.saintpetersburg.wordcamp.org

The solution I'd like

It'd be much faster and more convenient if --url accepted a substring, and performed a search if the string isn't an exact match for a domain.

e.g., wp shell --url=2019.saintp

To avoid any confusion, the command could output the full URL of the selected site when a substring is used:

> wp cron event list --url=2019.saintp

Running command against `https://2019.saintpetersburg.wordcamp.org`

+------------------------------------------+---------------------+-----------------------+---------------+
| hook                                     | next_run_gmt        | next_run_relative     | recurrence    |
+------------------------------------------+---------------------+-----------------------+---------------+
| wp_cache_gc                              | 2019-07-30 14:36:28 | 2 minutes 8 seconds   | Non-repeating |
...

That could be disabled when --quiet is set, though.

If multiple results are found for the given substring, then the safest thing to do might be to throw an error, and ask the user to provide a unique substring.

In mutli-network installs, it should probably just search all networks, since everything is stored in wp_blogs anyway.

wp_blogs has a domain index comprised of wp_blogs.domain and wp_blogs.path, so searching should be performant even in very large sites. If that doesn't turn out to be true, though, then the search could simply be disabled when wp_is_large_network(), and the user would have to specify an exact URL. That would only impact a relatively small number of WP-CLI users, though.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions