cwp wp
shipped 1.0.0cwp wp [args] [flags]
Acts on the local site unless an environment is named.
A conduit: standard output belongs to the program being run, so there is no --json and the exit code is forwarded unchanged.
| Argument | What it is | Default |
|---|---|---|
[args] | the WP-CLI command, after a mandatory -- |
| Flag | What it does | Default |
|---|---|---|
--env <env> | run against an environment instead of the local site |
Plus the shared flags --verbose and --dry-run.
What it does
The escape hatch: every WP-CLI command cwp does not wrap, without having to
remember whether this site wants ddev wp, cloudron exec --app <app> -- wp or
ssh <host> "cd <docroot> && wp".
The -- is mandatory. Everything before it belongs to cwp, everything after
it goes to WP-CLI untouched — which is what keeps --env or --verbose from
ever colliding with WP-CLI’s own --path, --format=json or --allow-root.
Leaving it out is a usage error with a fix hint, not a guess:
✗ cwp wp needs a `--` before the WP-CLI command
→ write it as `cwp wp -- plugin list`
Three things are deliberately not cwp’s business here:
- The terminal belongs to WP-CLI. stdio is inherited rather than captured, so
wp shellandwp db cliare interactive, output streams as it happens, and colour and progress bars survive. - The exit code is WP-CLI’s, forwarded verbatim, because a pass-through that
rewrites exit codes is useless in a script. cwp’s own refusals — a missing
--, an unknown environment, no project — all happen before WP-CLI starts and use cwp’s exit codes. - There is no
--json. stdout is WP-CLI’s payload and an envelope around it would corrupt it. Use WP-CLI’s own--format=json.
Example
cwp wp -- plugin list
cwp wp -- option get siteurl
cwp wp -- shell # interactive; the terminal is handed over
cwp wp --env dev -- option get siteurl
cwp wp --env prod --dry-run -- plugin list # see the exact command first
Getting data out of a site needs nothing from cwp beyond staying out of the way:
cwp wp --env dev -- post list --post_type=page --format=json
What it does not do
It is not guarded. cwp wp --env prod -- db query 'DROP TABLE …' runs. The
guard ladder applies to cwp’s own operations, not to arbitrary WP-CLI you asked
it to forward, and pretending otherwise would be the more dangerous claim.
--dry-run prints the exact command it would run and exits, which is the way to
check an unfamiliar one against a live environment before it happens.