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

Add `--all` flag to remove all terms from a post #23

Merged
merged 12 commits into from Jul 10, 2017

Conversation

3 participants
@BhargavBhandari90
Contributor

BhargavBhandari90 commented Jul 1, 2017

Add parameter to remove all terms from the particular post

Fixes #18

Show outdated Hide outdated src/WP_CLI/CommandWithTerms.php
Show outdated Hide outdated src/WP_CLI/CommandWithTerms.php
Show outdated Hide outdated src/WP_CLI/CommandWithTerms.php
@schlessera

This comment has been minimized.

Show comment
Hide comment
@schlessera
Member

schlessera commented Jul 1, 2017

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Jul 2, 2017

Contributor

Please add relevant functional tests for this

I tried running behat test.
When I tried to run ./vendor/bin/behat --expand, then I am getting below error

[RuntimeException]
$ mkdir -p "C:\Users\bunty\AppData\Local\Temp/wp-cli-test-cache"
A subdirectory or file -p already exists.
Error occurred while processing: -p.
A subdirectory or file C:\Users\bunty\AppData\Local\Temp/wp-cli-test-cache already exists.
Error occurred while processing: C:\Users\bunty\AppData\Local\Temp/wp-cli-test-cache.
cwd:
exit status: 1

Am I doing something wrong?

Contributor

BhargavBhandari90 commented Jul 2, 2017

Please add relevant functional tests for this

I tried running behat test.
When I tried to run ./vendor/bin/behat --expand, then I am getting below error

[RuntimeException]
$ mkdir -p "C:\Users\bunty\AppData\Local\Temp/wp-cli-test-cache"
A subdirectory or file -p already exists.
Error occurred while processing: -p.
A subdirectory or file C:\Users\bunty\AppData\Local\Temp/wp-cli-test-cache already exists.
Error occurred while processing: C:\Users\bunty\AppData\Local\Temp/wp-cli-test-cache.
cwd:
exit status: 1

Am I doing something wrong?

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Jul 3, 2017

Contributor

@schlessera All changes reported by you are done. Please review it.

Contributor

BhargavBhandari90 commented Jul 3, 2017

@schlessera All changes reported by you are done. Please review it.

@schlessera

This is not quite what I meant.

The general principle is that you want to reduce both indentation levels and the number of else branches that you have in your code. This helps reduce overally complexity, because your code ends up having less branches going on at the same time.

To achieve this, one popular and useful method is to bail early where it makes sense.

This can be done here by turning the code around.

So, instead of this:

} else {
   if ( $terms ) {
      $result = ...
   } else {
      WP_CLI::error( ... );
   }
}

we want to prefer this:

} else {
   if ( ! $terms ) {
      WP_CLI::error( ... );
   }
   $result = ...
}

This reduces the indentation level of the $result = ... statement, because we completed one possible branch above by exiting the code early if our condition is not met.

@danielbachhuber danielbachhuber changed the title from Feature/gh #18 to Add `--all` flag to remove all terms from a post Jul 4, 2017

@danielbachhuber danielbachhuber self-requested a review Jul 4, 2017

@danielbachhuber

Can you add functional tests please? Here's an introduction: https://make.wordpress.org/cli/handbook/pull-requests/

@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Jul 6, 2017

Contributor

@schlessera @danielbachhuber I have added the functional test for the feature. Please check this.

Contributor

BhargavBhandari90 commented Jul 6, 2017

@schlessera @danielbachhuber I have added the functional test for the feature. Please check this.

Show outdated Hide outdated src/WP_CLI/CommandWithTerms.php
Show outdated Hide outdated features/post-term.feature
Show outdated Hide outdated src/WP_CLI/CommandWithTerms.php
@BhargavBhandari90

This comment has been minimized.

Show comment
Hide comment
@BhargavBhandari90

BhargavBhandari90 Jul 8, 2017

Contributor

@schlessera @danielbachhuber All changes are done. Please confirm this.

Contributor

BhargavBhandari90 commented Jul 8, 2017

@schlessera @danielbachhuber All changes are done. Please confirm this.

@danielbachhuber

This comment has been minimized.

Show comment
Hide comment
@danielbachhuber

danielbachhuber Jul 10, 2017

Member

@BhargavBhandari90 Thanks for your work on this!

Member

danielbachhuber commented Jul 10, 2017

@BhargavBhandari90 Thanks for your work on this!

@danielbachhuber danielbachhuber merged commit 253caa3 into wp-cli:master Jul 10, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment