wp-cli / search-replace-command

Searches/replaces strings in the database.
MIT License
57 stars 45 forks source link

Add associated args --new and --old #150

Closed marksabbath closed 1 year ago

marksabbath commented 3 years ago

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

schlessera commented 2 years ago

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.

marksabbath commented 2 years ago

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 commented 2 years ago

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

danielbachhuber commented 1 year ago

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.