Skip to content

Commit 05f4ba0

Browse files
authored
Merge pull request #39 from wp-cli/revert-37
Revert #37 to remove `--stdout` for `wp db export`
2 parents 17e2438 + 31bc9e4 commit 05f4ba0

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

features/db-export.feature

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,3 @@ Feature: Export a WordPress database
4242
"""
4343
-- MySQL dump
4444
"""
45-
46-
When I run `wp db export --stdout`
47-
Then STDOUT should contain:
48-
"""
49-
-- MySQL dump
50-
"""
51-
52-
When I try `wp db export - --stdout`
53-
Then STDERR should be:
54-
"""
55-
Error: The file name is not allowed when output mode is STDOUT.
56-
"""

src/DB_Command.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,6 @@ public function query( $args, $assoc_args ) {
269269
* [--exclude_tables=<tables>]
270270
* : The comma separated list of specific tables that should be skipped from exporting. Excluding this parameter will export all tables in the database.
271271
*
272-
* [--stdout]
273-
* : Output database to STDOUT.
274-
*
275272
* [--porcelain]
276273
* : Output filename for the exported database.
277274
*
@@ -306,7 +303,7 @@ public function query( $args, $assoc_args ) {
306303
* Success: Exported to 'wordpress_dbase-db72bb5.sql'.
307304
*
308305
* # Export database to STDOUT.
309-
* $ wp db export --stdout
306+
* $ wp db export -
310307
* -- MySQL dump 10.13 Distrib 5.7.19, for osx10.12 (x86_64)
311308
* --
312309
* -- Host: localhost Database: wpdev
@@ -323,19 +320,7 @@ public function export( $args, $assoc_args ) {
323320
$hash = substr( md5( mt_rand() ), 0, 7 );
324321
$result_file = sprintf( '%s-%s-%s.sql', DB_NAME, date( 'Y-m-d' ), $hash );;
325322
}
326-
327-
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'stdout' ) && ! empty( $args[0] ) ) {
328-
WP_CLI::error( 'The file name is not allowed when output mode is STDOUT.' );
329-
}
330-
331-
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'stdout' ) ) {
332-
$stdout = true;
333-
} elseif ( '-' === $result_file ) {
334-
$stdout = true;
335-
} else {
336-
$stdout = false;
337-
}
338-
323+
$stdout = ( '-' === $result_file );
339324
$porcelain = \WP_CLI\Utils\get_flag_value( $assoc_args, 'porcelain' );
340325

341326
// Bail if both porcelain and STDOUT are set.
@@ -375,7 +360,6 @@ public function export( $args, $assoc_args ) {
375360

376361
// Remove parameters not needed for SQL run.
377362
unset( $assoc_args['porcelain'] );
378-
unset( $assoc_args['stdout'] );
379363

380364
self::run( $escaped_command, $assoc_args );
381365

0 commit comments

Comments
 (0)