diff --git a/src/Import_Command.php b/src/Import_Command.php index 03a3178ad..495591a20 100644 --- a/src/Import_Command.php +++ b/src/Import_Command.php @@ -65,18 +65,32 @@ public function __invoke( $args, $assoc_args ) { if ( ! empty( $files ) ) { $new_args = array_merge( $new_args, $files ); } + + if ( empty( $files ) ) { + WP_CLI::warning( "No files found in the import dir '$arg'." ); + } } else { - if ( file_exists( $arg ) ) { + if ( ! file_exists( $arg ) ) { + WP_CLI::warning( "'$arg' doesn't exist." ); + continue; + } + + if ( is_readable( $arg ) ) { $new_args[] = $arg; + continue; } + + WP_CLI::warning( "Can't read '$arg' file." ); } } + + if ( empty( $new_args ) ) { + WP_CLI::error( "Import failed due to missing or unreadable file/s." ); + } + $args = $new_args; foreach ( $args as $file ) { - if ( ! is_readable( $file ) ) { - WP_CLI::warning( "Can't read '$file' file." ); - } $ret = $this->import_wxr( $file, $assoc_args );