-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Feature Request
- Yes, I reviewed the contribution guidelines.
Describe your use case and the problem you are facing
Today with WP-CLI I can check if a value is set with wp config has, and get its value with wp config get, but if I want to check if the value is true, I still need to assert with a bash test, like [[ "$(wp config get FOO)" == 1 ]].
wp config ... is useful because it parses wp-config, but does not bootstrap WordPress. At times, it is useful to check these values without loading WordPress. Otherwise, this can be accomplished (at least for constants) with wp eval 'exit((defined("FOO") && FOO) ? 0 : 1);'
A clear and concise description of what you are actually trying to do, and in what way the current version of WP-CLI is not up to the task.
Describe the solution you'd like
wp config true <name> would assert if a config value is “truthy”, and exit non-zero if it is false. In this way, we could use exit codes to simplify our tests to something like if wp config true FOO; then ...
This also lets us sidestep PHP notices getting captured per wp-cli/wp-cli#5809.
When I get the time, I intend to PR an attempt at this...