-
Notifications
You must be signed in to change notification settings - Fork 94
Add wp option get-autoload and wp option set-autoload
#382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6f2a611
Add `wp option get-autoload` and `wp option set-autoload`
danielbachhuber 60ef1d7
Add a step for running the same command again
danielbachhuber 89a5e6b
Clean up PHPCS issues
danielbachhuber d25be6e
Use the constant instead for WP 3.7 compat
danielbachhuber 929f020
Remove unnecessary confusion from comment
danielbachhuber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| Feature: Get 'autoload' value for an option | ||
|
|
||
| Scenario: Option doesn't exist | ||
| Given a WP install | ||
|
|
||
| When I try `wp option get-autoload foo` | ||
| Then STDERR should be: | ||
| """ | ||
| Error: Could not get 'foo' option. Does it exist? | ||
| """ | ||
|
|
||
| Scenario: Displays 'autoload' value | ||
| Given a WP install | ||
|
|
||
| When I run `wp option add foo bar` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: | ||
| """ | ||
|
|
||
| When I run `wp option get-autoload foo` | ||
| Then STDOUT should be: | ||
| """ | ||
| yes | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| Feature: Set 'autoload' value for an option | ||
|
|
||
| Scenario: Option doesn't exist | ||
| Given a WP install | ||
|
|
||
| When I try `wp option set-autoload foo yes` | ||
| Then STDERR should be: | ||
| """ | ||
| Error: Could not get 'foo' option. Does it exist? | ||
| """ | ||
|
|
||
| Scenario: Invalid 'autoload' value provided | ||
| Given a WP install | ||
|
|
||
| When I run `wp option add foo bar` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: | ||
| """ | ||
|
|
||
| When I try `wp option set-autoload foo invalid` | ||
| Then STDERR should be: | ||
| """ | ||
| Error: Invalid value specified for positional arg. | ||
| """ | ||
|
|
||
| Scenario: Successfully updates autoload value | ||
| Given a WP install | ||
|
|
||
| When I run `wp option add foo bar` | ||
| Then STDOUT should contain: | ||
| """ | ||
| Success: | ||
| """ | ||
|
|
||
| When I run `wp option get-autoload foo` | ||
| Then STDOUT should be: | ||
| """ | ||
| yes | ||
| """ | ||
|
|
||
| When I run `wp option set-autoload foo no` | ||
| Then STDOUT should be: | ||
| """ | ||
| Success: Updated autoload value for 'foo' option. | ||
| """ | ||
|
|
||
| When I run the previous command again | ||
| Then STDOUT should be: | ||
| """ | ||
| Success: Autoload value passed for 'foo' option is unchanged. | ||
| """ | ||
|
|
||
| When I run `wp option get-autoload foo` | ||
| Then STDOUT should be: | ||
| """ | ||
| no | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means the API is:
That seems to be forced by the DB value and is neither developer-speak (set autoload true) nor natural language (disable autoload).
I'm don't love that API, but I have trouble coming up with something better.
What do think about:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schlessera Good points. I don't love your proposed approach either because it seems unnecessarily complex to nest the commands further.
I went with
wp option set-autoload my_option nobecausewp option addaccepts--autoload=yes/--autoload=no.