Skip to content

Commit c286afe

Browse files
committed
rewriting to optimize
1 parent 24dec4a commit c286afe

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

features/post-generate.feature

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ Feature: Generate new WordPress posts
1212
"""
1313
And STDERR should be empty
1414

15+
When I try `wp post generate --count=1 --post_content`
16+
Then STDERR should contain:
17+
"""
18+
Error: The parameter `post_content` reads from STDIN.
19+
"""
20+
1521
Scenario: Generating posts by a specific author
1622

1723
When I run `wp user create dummyuser dummy@example.com --porcelain`

src/Post_Command.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,10 +711,10 @@ public function generate( $args, $assoc_args ) {
711711
}
712712

713713
if ( !empty( \WP_CLI\Utils\get_flag_value( $assoc_args, 'post_content' ) ) ) {
714-
WP_CLI::error( "The parameter `post_content` reads from STDIN." );
715-
}
716-
717-
if ( \WP_CLI\Entity\Utils::has_stdin() && \WP_CLI\Utils\get_flag_value( $assoc_args, 'post_content' ) ) {
714+
if ( !\WP_CLI\Entity\Utils::has_stdin() ) {
715+
WP_CLI::error( "The parameter `post_content` reads from STDIN." );
716+
}
717+
718718
$post_content = file_get_contents( 'php://stdin' );
719719
}
720720

0 commit comments

Comments
 (0)