OSDN Git Service

add --format parameter to meta get and update
authorscribu <mail@scribu.net>
Sun, 19 May 2013 16:40:31 +0000 (19:40 +0300)
committerscribu <mail@scribu.net>
Sun, 19 May 2013 16:49:33 +0000 (19:49 +0300)
php/WP_CLI/CommandWithMeta.php

index 3ec480e..6695d1e 100644 (file)
@@ -14,7 +14,7 @@ abstract class CommandWithMeta extends \WP_CLI_Command {
        /**
         * Get meta field value.
         *
-        * @synopsis <id> <key> [--json]
+        * @synopsis <id> <key> [--format=<format>]
         */
        public function get( $args, $assoc_args ) {
                list( $object_id, $meta_key ) = $args;
@@ -47,10 +47,12 @@ abstract class CommandWithMeta extends \WP_CLI_Command {
        /**
         * Add a meta field.
         *
-        * @synopsis <id> <key> <value>
+        * @synopsis <id> <key> <value> [--format=<format>]
         */
        public function add( $args, $assoc_args ) {
-               list( $object_id, $meta_key, $meta_value ) = $args;
+               list( $object_id, $meta_key ) = $args;
+
+               $meta_value = \WP_CLI::read_value( $args[2], $assoc_args );
 
                $success = \add_metadata( $this->meta_type, $object_id, $meta_key, $meta_value );
 
@@ -65,10 +67,12 @@ abstract class CommandWithMeta extends \WP_CLI_Command {
         * Update a meta field.
         *
         * @alias set
-        * @synopsis <id> <key> <value>
+        * @synopsis <id> <key> <value> [--format=<format>]
         */
        public function update( $args, $assoc_args ) {
-               list( $object_id, $meta_key, $meta_value ) = $args;
+               list( $object_id, $meta_key ) = $args;
+
+               $meta_value = \WP_CLI::read_value( $args[2], $assoc_args );
 
                $success = \update_metadata( $this->meta_type, $object_id, $meta_key, $meta_value );