Skip to content

Commit 2ef8fad

Browse files
authored
Merge pull request #126 from thrijith/GH-123
display error message when option does not exist
2 parents f1c43e6 + 57462a2 commit 2ef8fad

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

features/option.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ Feature: Manage WordPress options
6464
"""
6565

6666
When I try `wp option get str_opt`
67-
Then the return code should be 1
68-
And STDERR should be empty
67+
Then STDERR should be:
68+
"""
69+
Error: Could not get 'str_opt' option. Does it exist?
70+
"""
6971

7072
# Integer values
7173
When I run `wp option update blog_public 1`

src/Option_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function get( $args, $assoc_args ) {
7676
$value = get_option( $key );
7777

7878
if ( false === $value ) {
79-
WP_CLI::halt( 1 );
79+
WP_CLI::error( "Could not get '$key' option. Does it exist?" );
8080
}
8181

8282
WP_CLI::print_value( $value, $assoc_args );

0 commit comments

Comments
 (0)