search-replace-command icon indicating copy to clipboard operation
search-replace-command copied to clipboard

Add associated args --new and --old

Open marksabbath opened this issue 5 years ago • 3 comments

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'.

marksabbath avatar Nov 22 '20 19:11 marksabbath

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.

schlessera avatar Jan 05 '22 23:01 schlessera

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. 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 :)

marksabbath avatar Jan 06 '22 17:01 marksabbath

Hey @schlessera would you mind taking another look at this PR?

marksabbath avatar Jul 25 '22 14:07 marksabbath

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.

danielbachhuber avatar Nov 18 '22 17:11 danielbachhuber