Skip to content

Commit 3beed71

Browse files
More edits
1 parent fc80907 commit 3beed71

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
---
22
layout: post
33
author: danielbachhuber
4-
title: RESTful WP-CLI - Coming to you soon?
4+
title: RESTful WP-CLI - The final update?
55
---
66

7-
Last November, I published a Kickstarter, and was completely blown away by the support. This month, the funding ran out, so I thought I'd post one last RESTful WP-CLI update.
7+
Last November, I [published a Kickstarter](https://www.kickstarter.com/projects/danielbachhuber/a-more-restful-wp-cli), and was completely blown away by the support. This month, the funding ran out, so I thought I'd post one last [RESTful WP-CLI](https://github.com/wp-cli/restful) update.
88

9-
Actually, the story doesn't end here. I'm writing a massive retrospective post on using Kickstarter to fund open source, so keep an eye out for that. Also, WP-CLI v0.24.0 is due out a week from now, July 27th, and it's looking to be the largest release ever. When you do a Kickstarter, it's really just the beginning of something bigger.
9+
Actually, the story doesn't end here. I'm writing a massive retrospective post about using Kickstarter to fund open source, so keep an eye out for that. Also, WP-CLI v0.24.0 is due out a week from now, July 27th, and it's looking to be the largest release ever. When you do a Kickstarter, it's really just the beginning of something bigger.
1010

11-
Enough with the superlatives, let's dive into some new features ...and remember: RESTful WP-CLI features have required under the hood changes to WP-CLI. You'll want to `wp cli update --nightly` to play with this new functionality locally. Once you've done so, you can `wp package install wp-cli/restful` to install the latest.
11+
Enough with the superlatives, let's dive into some new features. Remember: RESTful WP-CLI features require under the hood changes to WP-CLI. You'll want to `wp cli update --nightly` to play with this new functionality locally. Once you've done so, you can `wp package install wp-cli/restful` to install the latest.
1212

1313
### Effortlessly use WP-CLI against any WordPress install
1414

15-
WP-CLI aliases are shortcuts you can register in your `wp-cli.yml` or `config.yml` to effortlessly run commands against any WordPress install.
15+
WP-CLI aliases are shortcuts you register in your `wp-cli.yml` or `config.yml` to effortlessly run commands against any WordPress install.
1616

17-
For instance, if I'm working on the runcommand theme on my local machine, have registered a new rewrite rule, and need to flush rewrites on my virtual machine, I can run:
17+
For instance, if I'm working locally on the runcommand theme, have registered a new rewrite rule, and need to flush rewrites inside my Vagrant-based virtual machine, I can run:
1818

1919
$ wp @dev rewrite flush
2020
Success: Rewrite rules flushed.
@@ -24,13 +24,15 @@ Then, once the code goes to production, I can run:
2424
$ wp @prod rewrite flush
2525
Success: Rewrite rules flushed.
2626

27-
Or, if I wanted to issue a command against both runcommand WordPress instances, I can use my `@both` alias group:
27+
Look ma! No more SSH'ing into machines, changing directories, and generally spending a full minute get to a given WordPress install.
28+
29+
Additionally, alias groups let you register groups of aliases. If I want to run a command against both runcommand WordPress instances, I can use `@both`:
2830

2931
$ wp @both core check-update
3032
Success: WordPress is at the latest version.
3133
Success: WordPress is at the latest version.
3234

33-
These aliases are registered in my project's `wp-cli.yml` file:
35+
Aliases can be registered in your project's `wp-cli.yml` file, or your user's global `~/.wp-cli/config.yml` file:
3436

3537
@prod:
3638
ssh: runcommand@runcommand.io~/webapps/production
@@ -44,19 +46,19 @@ These aliases are registered in my project's `wp-cli.yml` file:
4446

4547
WP-CLI now natively supports a `--ssh=<host>` global parameter for running a command against a remote WordPress install. Many thanks to XWP and their community for paving the way with [WP-CLI SSH](https://github.com/xwp/wp-cli-ssh).
4648

47-
Under the hood, WP-CLI proxies to the `ssh` executable. Your syntax for `<host>` can be any of the following:
49+
Under the hood, WP-CLI proxies commands to the `ssh` executable, which then passes them to WP-CLI installed on the remote machine. Your syntax for `-ssh=<host>` can be any of the following:
4850

4951
* Just the host (e.g. `wp --ssh=runcommand.io`), which means the user will be inferred from your current system user, and the path will be the SSH user's home directory.
5052
* The user and the host (e.g. `wp --ssh=runcommand@runcommand.io`).
5153
* The user, the host, and the path to the WordPress install (e.g. `wp --ssh=runcommand@runcommand.io~/webapps/production`). The path comes immediately after the TLD of the host.
5254

5355
Or, if you use a `~/.ssh/config`, `<host>` can be any host alis stored in the SSH config (e.g. `wp --ssh=rc` for me).
5456

55-
Note you will need a copy of WP-CLI on the remote server, accessible as `wp`. Using `--ssh=<host>` won't load your `.bash_profile` if you have a shell alias defined there. [Here's a more thorough explanation](https://runcommand.io/to/wp-ssh-custom-path/) of how you can make `wp` accessible.
57+
Note you do need a copy of WP-CLI on the remote server, accessible as `wp`. Futhermore, `--ssh=<host>` won't load your `.bash_profile` if you have a shell alias defined, or are extending the `$PATH` environment variable. If this affects you, [here's a more thorough explanation](https://runcommand.io/to/wp-ssh-custom-path/) of how you can make `wp` accessible.
5658

5759
### RESTful WP-CLI v0.2.0 and beyond
5860

59-
Today also marks the release of [RESTful WP-CLI](https://github.com/wp-cli/restful) v0.2.0. Among [43 closed issues and pull requests](https://github.com/wp-cli/restful/milestone/2?closed=1), I'd like to highlight two new features.
61+
Today marks the release of [RESTful WP-CLI](https://github.com/wp-cli/restful) v0.2.0. Among [43 closed issues and pull requests](https://github.com/wp-cli/restful/milestone/2?closed=1), I'd like to highlight two new features.
6062

6163
First, use `wp rest (post|user|comment|*) generate` to create an arbitrary number of any resource:
6264

@@ -65,6 +67,8 @@ First, use `wp rest (post|user|comment|*) generate` to create an arbitrary numbe
6567

6668
When working on a site locally, you often need dummy content to work with. There are a myriad of ways custom post types can store data in the database though, so generating dummy content can be a painstaking process. Because the WP REST API represents a layer of abstraction between the client (e.g. WP-CLI in this case) and the database, it's much easier to produce a general purpose content generation command.
6769

70+
In the future, I'd love to see [dummy data generated for each field based on the resource schema](https://github.com/wp-cli/restful/issues/69).
71+
6872
Second, use `wp rest (post|user|comment|*) diff` to compare resources between two enviroments:
6973

7074
$ wp @dev rest command diff @prod find-unused-themes --fields=title
@@ -74,6 +78,8 @@ Second, use `wp rest (post|user|comment|*) diff` to compare resources between tw
7478

7579
When working with multiple WordPress environments, you may want to know how these environments differ. Because the WP REST API represents a higher-level abstraction on top of WordPress, computing the difference between two environments becomes a matter of fetching the data and producing a comparison.
7680

77-
Consider both of these new features to be prototypes. They work, but there are many implementation details to be worked out.
81+
There are a [number of ways the diff command could be improved](https://github.com/wp-cli/restful/issues?q=is%3Aissue+is%3Aopen+label%3Acommand%3Adiff), so consider this implementation to be the prototype.
82+
83+
What's next? Ultimately, the goal is for `wp rest post` to replace `wp post`, but there are many months between here and there. In this future where WP-CLI packages are first-class citizens amongst the commands in WP-CLI core, RESTful WP-CLI gets to serve as a testbed for figuring out how that actually works. We shall see, we shall see.
7884

79-
tk closing
85+
As always, thanks for your support!

0 commit comments

Comments
 (0)