Skip to content

Commit 65181e5

Browse files
authored
Merge pull request #189 from Mte90/stdin
Check for `STDIN` if `--post_content` is used
2 parents cfe115a + 3a40f0c commit 65181e5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

features/post-generate.feature

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

15+
@broken
16+
Scenario: Using --post-content requires STDIN input
17+
When I try `wp post generate --count=1 --post_content`
18+
Then STDERR should contain:
19+
"""
20+
Error: The parameter `post_content` reads from STDIN.
21+
"""
22+
1523
Scenario: Generating posts by a specific author
1624

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

src/Post_Command.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,10 @@ public function generate( $args, $assoc_args ) {
729729
}
730730

731731
if ( \WP_CLI\Utils\get_flag_value( $assoc_args, 'post_content' ) ) {
732+
if ( ! \WP_CLI\Entity\Utils::has_stdin() ) {
733+
WP_CLI::error( 'The parameter `post_content` reads from STDIN.' );
734+
}
735+
732736
$post_content = file_get_contents( 'php://stdin' );
733737
}
734738

0 commit comments

Comments
 (0)