OSDN Git Service

Merge pull request #817 from x-team:mysqldump-extra-args
authorscribu <mail@scribu.net>
Tue, 7 Jan 2014 23:44:39 +0000 (01:44 +0200)
committerscribu <mail@scribu.net>
Tue, 7 Jan 2014 23:44:39 +0000 (01:44 +0200)
1  2 
php/commands/db.php

@@@ -109,28 -111,18 +109,35 @@@ class DB_Command extends WP_CLI_Comman
        }
  
        /**
 -       * Exports the database using mysqldump. Accepts all of mysqldump's arguments.
 +       * Exports the database to a file or to STDOUT.
         *
 -       * @alias dump
 +       * ## OPTIONS
 +       *
 +       * [<file>]
 +       * : The name of the SQL file to export. If '-', then outputs to STDOUT. If omitted, it will be '{dbname}.sql'.
 +       *
++       * [--<field>=<value>]
++       * : Extra arguments to pass to mysqldump
++       *
++       * ## EXAMPLES
+        *
 -       * @synopsis [<file>] [--extended-insert] [--skip-comments] [--<field>=<value>]
++       *     wp db dump --add-drop-table
++       *
 +       * @alias dump
         */
        function export( $args, $assoc_args ) {
 -              $assoc_args['result-file'] = $this->get_file_name( $args );
 +              $result_file = $this->get_file_name( $args );
 +              $stdout = ( '-' === $result_file );
 +
-               $cmd_args = array();
 +              if ( ! $stdout ) {
-                       $cmd_args['result-file'] = $result_file;
++                      $assoc_args['result-file'] = $result_file;
 +              }
-               self::run( Utils\esc_cmd( 'mysqldump %s', DB_NAME ), $cmd_args );
+               self::run( Utils\esc_cmd( 'mysqldump %s', DB_NAME ), $assoc_args );
  
 -              WP_CLI::success( sprintf( 'Exported to %s', $assoc_args['result-file'] ) );
 +              if ( ! $stdout ) {
 +                      WP_CLI::success( sprintf( 'Exported to %s', $result_file ) );
 +              }
        }
  
        /**