search-replace-command
search-replace-command copied to clipboard
Add associated args --new and --old
This PR introduces 2 new associated arguments to the search-replace command in an effort to resolve the bug reported on #132
With this approach, if users need to replace strings starting with more than one dash (i.e --mystring) they will be able to do that by using the new associated arguments: wp search-replace --old='--oldstring' --new='newstring'.
We need to check whether both $old and $new were provided by the user, in any combination.
As you've probably noticed, we cannot check this based on the value of the arguments, as an empty string is a valid value (at least for $new), so we have to check based on the presence of the arguments/flags instead.
Also, we'll need functional tests to ensure the flags work as expected.
We need to check whether both
$oldand$newwere provided by the user, in any combination.As you've probably noticed, we cannot check this based on the value of the arguments, as an empty string is a valid value (at least for
$new), so we have to check based on the presence of the arguments/flags instead. Great point @schlessera I'll work on that.
Also, we'll need functional tests to ensure the flags work as expected. Yeah, I rebased with that purpose. I'll work on that on my next round :)
Hey @schlessera would you mind taking another look at this PR?
Proceeding with https://github.com/wp-cli/wp-cli/issues/5594 for this repository. I've captured this PR to https://gist.github.com/danielbachhuber/6c398217cff94e8a23a94b6b23aca3aa in case this PR is auto-closed or broken in some way.