`wp config create` would benefit from clear path to defer all parameter initialization.
It would seem to me that the optional/required parameters for wp config create are a little overbearing, especially considering the capabilities of wp config set. I don't see a strong reason why all of the parameters shouldn't be optional.
Verification is important, but given the wide variety of environments out there, the host/user only requirement seems very over/under in regards to actually having all the info to verify a connection (I'm assuming the purpose of them being required is to conduct that test).
Given the kitchen sink list of parameters possibly required, and the comparative ease of use of wp config set. It would be nice if there was an official, clearly indicated way to jump over to the for-each usage style.
I would prefer a flag that indicates this intention and skips the checks, but the command documentation could more clearly steer users to this possibility, as well.
I'm sure many users, like myself, are also interested in simplifying the injection of these parameters from the environment variables already present in their Docker container. At that point, you are already for-eaching in a bunch of (possibly missing) parameters, so why not include the other two.
To illustrate my process/point:
If setting up an environment like this:
$ docker run -it --rm wordpress:cli bash
bash-5.1$ wp core download --skip-content
Downloading WordPress 5.7 (en_US)...
md5 hash verified: b3033cdce55dd8c9af9eaed9233475d4
Success: WordPress downloaded.
This use case should have a shorthand flag, i.e. wp config create --template.
bash-5.1$ wp --skip-check config create --dbname= --dbuser=
Success: Generated 'wp-config.php' file.
To support setting all parameters in a for-each style like this (unrolled for clarity):
bash-5.1$ wp config set DB_NAME wordpress
Success: Updated the constant 'DB_NAME' in the 'wp-config.php' file with the value 'wordpress'.
bash-5.1$ wp config set DB_USER root
Success: Updated the constant 'DB_USER' in the 'wp-config.php' file with the value 'root'.
bash-5.1$ wp config set DB_PASSWORD example
Success: Updated the constant 'DB_PASSWORD' in the 'wp-config.php' file with the value 'example'.
Thanks for the suggestion, @JollyWizard !
I'm open to the idea of making --dbname=<dbname> and --dbuser=<dbuser> optional. This is relevant for SQLite support too (https://github.com/wp-cli/config-command/issues/167). However, if we did so, we'd need to mark it as a breaking change, because there's some rare scenario where a script could be dependent on the current error behavior if dbname or dbuser are missing.
We're likely to tag a WP-CLI 3.0.0 in the next year (https://github.com/wp-cli/wp-cli/milestone/70), and could include this change in that release.
Another option (not necessarily a good one) is to introduce a wp config init or similar command that makes a very basic wp-config.php and incorporates different behavior.
cc @wp-cli/committers if there are other opinions.
I'd really like to see that in wp 3.0. Whatever the solution used, this would be really useful.