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

Subcommands for working with multi-dimensional values #42

Closed
aaemnnosttv opened this issue May 25, 2017 · 4 comments
Closed

Subcommands for working with multi-dimensional values #42

aaemnnosttv opened this issue May 25, 2017 · 4 comments

Comments

@aaemnnosttv
Copy link

E.g.

wp_update_option('example_option', array('foo' => 'bar'));
wp option pluck example_option foo
# or 
wp option get example_option --key=foo

Returns bar

wp option patch example_option foo baz
# or
wp option set example_option --key=foo baz

Updates bar to baz

Ideally it would be great to be able to use dot notation using the normal functions, but option names could contain dots or really any other character that could be used to separate hierarchy.

e.g.

wp option get example_option.foo

Returns bar

This same idea could be applied to just about all get set commands, for meta, transient, etc.

@danielbachhuber
Copy link
Member

wp option pluck and wp option patch are interesting approaches.

The dot notation idea came up before (might've been you, can't find the issue), but option names can contain dots.

@schlessera
Copy link
Member

I think the get and set variations are too error-prone. Way too easy to unintentionally overwrite your entire option array.

pluck and patch would make this more explicit, the opportunity for error is therefore reduced.

@aaemnnosttv
Copy link
Author

Are you guys open to a PR for pluck and patch?

@schlessera
Copy link
Member

@aaemnnosttv Yes, these might come in handy, and this specific approach is the safest one we are aware of.

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

No branches or pull requests

3 participants