Skip to content

Commit 9689134

Browse files
Issue #374 : Add examples for wp option patch command (#375)
1 parent 9f542ef commit 9689134

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Option_Command.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,32 @@ function( $key ) {
548548
* - plaintext
549549
* - json
550550
* ---
551+
*
552+
* ## EXAMPLES
553+
*
554+
* # Add 'bar' to the 'foo' key on an option with name 'option_name'
555+
* $ wp option patch insert option_name foo bar
556+
* Success: Updated 'option_name' option.
557+
*
558+
* # Update the value of 'foo' key to 'new' on an option with name 'option_name'
559+
* $ wp option patch update option_name foo new
560+
* Success: Updated 'option_name' option.
561+
*
562+
* # Set nested value of 'bar' key to value we have in the patch file on an option with name 'option_name'.
563+
* $ wp option patch update option_name foo bar < patch
564+
* Success: Updated 'option_name' option.
565+
*
566+
* # Update the value for the key 'not-a-key' which is not exist on an option with name 'option_name'.
567+
* $ wp option patch update option_name foo not-a-key new-value
568+
* Error: No data exists for key "not-a-key"
569+
*
570+
* # Update the value for the key 'foo' without passing value on an option with name 'option_name'.
571+
* $ wp option patch update option_name foo
572+
* Error: Please provide value to update.
573+
*
574+
* # Delete the nested key 'bar' under 'foo' key on an option with name 'option_name'.
575+
* $ wp option patch delete option_name foo bar
576+
* Success: Updated 'option_name' option.
551577
*/
552578
public function patch( $args, $assoc_args ) {
553579
list( $action, $key ) = $args;

0 commit comments

Comments
 (0)