Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the config command consistent by providing "list" and "get". #14

Closed
wants to merge 1 commit into from

Conversation

schlessera
Copy link
Member

To make the wp config command more consistent with the way the rest of the commands behave, and to add needed functionality, I renamed the current wp config get command (which displays a list of all values) into wp config list, and added a new wp config get <key> command to retrieve the value of a specific key.

This allows one to use something like wp config get table_prefix to quickly get one particular value.

To make the `wp config` command more consistent with the way the rest of the commands behave, and to add needed functionality, I renamed the current `wp config get` command (which displays a list of all values) into `wp config list`, and added a new `wp config get <key>` command to retrieve the value of a specific key.

This allows one to use something like `wp config get table_prefix` to quickly get one particular value.
@schlessera schlessera changed the title Make the config command consistent by provideing "list" and "get". Make the config command consistent by providing "list" and "get". May 31, 2017
@danielbachhuber
Copy link
Member

👎

I patterned wp config get after wp post get, which displays all fields.

The established pattern is:

  • wp * list is for listing a collection of objects.
  • wp * get is for getting an individual object.
  • wp * get --field=<field> is for getting the value of a specific field.

@danielbachhuber danielbachhuber deleted the make-config-command-consistent branch May 31, 2017 13:42
@schlessera
Copy link
Member Author

Well, the problem is that wp * get --field=<field> does not work as expected. The collection of objects is the collection of variables/constants here.

If you do wp * get --field=<field>, <field> is the column, meaning key, value or type. That is mostly useless.

There's no way to fetch a single value right now.

@schlessera
Copy link
Member Author

Just try getting the table_prefix... :)

@danielbachhuber
Copy link
Member

Sure, it's not implemented yet. We could add this pattern: wp config get --global=table_prefix or wp config get --constant=DB_NAME

@schlessera
Copy link
Member Author

schlessera commented May 31, 2017

If you model it as described above, it is meant to manage a "collection of wp-config.php files", which is not logical. And a single "item" is all of the contents of one wp-config.php file.

So, to compare posts vs configs...

Your approach:
list => collection of posts, collection of wp-config.php files
get => single post, single wp-config.php file
get --field => single post column, single wp-config.php file value

My approach:
list => collection of posts, collection of wp-config.php entries
get => single post, single wp-config.php entry
get --field => single post column, unneeded as a wp-config.php entry only has one column

@danielbachhuber
Copy link
Member

If you model it as described above, it is meant to manage a "collection of wp-config.php files", which is not logical. And a single "item" is all of the contents of one wp-config.php file.

"Not logical" is your opinion. If you consider Configuration as an abstract entity where a Configuration contains a variety of globals and constants, then it is a logical model.

Furthermore, and more importantly, my model is consistent with the rest of WP-CLI, meaning there's no mental overhead when using it.

get => single post, single wp-config.php entry
get --field => single post column, unneeded as a wp-config.php entry only has one column

This wouldn't work, because globals and constants can have the same name. You'd always need a --type=<type> clarifier.

@schlessera
Copy link
Member Author

I rather meant "not intuitive". I know a bit about WP-CLI, but I have spent 10 minutes trying to figure out how to get the table_prefix. :) I was just assuming that wp config get would get me a config value, not the entire config.

@danielbachhuber
Copy link
Member

Furthermore, we already have wp config create, which creates an entire wp-config.php file, not an individual value, and wp config path, which provides the path to the wp-config.php file.

I know a bit about WP-CLI, but I have spent 10 minutes trying to figure out how to get the table_prefix. :) I was just assuming that wp config get would get me a config value, not the entire config.

Sure, let's add support for getting individual values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants