diff --git a/packages/env/README.md b/packages/env/README.md index d9ac0d2440a6fb..4b7eedc02c57fa 100644 --- a/packages/env/README.md +++ b/packages/env/README.md @@ -43,7 +43,7 @@ Then, start the local environment: $ wp-env start ``` -Finally, navigate to http://localhost:8888 in your web browser to see WordPress running with the local WordPress plugin or theme running and activated. +Finally, navigate to http://localhost:8888 in your web browser to see WordPress running with the local WordPress plugin or theme running and activated. Default login credentials are username: `admin` password: `password`. ### Stopping the environment @@ -175,6 +175,32 @@ Positionals: [string] [choices: "all", "development", "tests"] [default: "tests"] ``` +### `wp-env run [container] [command]` + +```sh +wp-env run [command..] + +Runs an arbitrary command in one of the underlying Docker containers, for +example it's useful for running wp cli commands. + + +Positionals: + container The container to run the command on. [string] [required] + command The command to run. [array] [default: []] +``` + +For example: + +```sh +wp-env run cli wp user list +⠏ Running `wp user list` in 'cli'. + +ID user_login display_name user_email user_registered roles +1 admin admin wordpress@example.com 2020-03-05 10:45:14 administrator + +✔ Ran `wp user list` in 'cli'. (in 2s 374ms) +``` + ## .wp-env.json You can customize the WordPress installation, plugins and themes that the development environment will use by specifying a `.wp-env.json` file in the directory that you run `wp-env` from. diff --git a/packages/env/lib/cli.js b/packages/env/lib/cli.js index 2ddc209e376f58..0a446a983db704 100644 --- a/packages/env/lib/cli.js +++ b/packages/env/lib/cli.js @@ -111,7 +111,7 @@ module.exports = function cli() { ); yargs.command( 'run [command..]', - 'Runs an arbitrary command in one of the underlying Docker containers.', + "Runs an arbitrary command in one of the underlying Docker containers, for example it's useful for running wp cli commands.", ( args ) => { args.positional( 'container', { type: 'string', @@ -124,6 +124,10 @@ module.exports = function cli() { }, withSpinner( env.run ) ); + yargs.example( + '$0 run cli wp user list', + 'Runs `wp user list` wp-cli command which lists WordPress users.' + ); return yargs; };