Skip to content

Commit 77fb3eb

Browse files
committed
Make <old> and <new> optional
1 parent f4eda28 commit 77fb3eb

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contr
1010
## Using
1111

1212
~~~
13-
wp search-replace <old> <new> [<table>...] [--dry-run] [--network] [--all-tables-with-prefix] [--all-tables] [--export[=<file>]] [--export_insert_size=<rows>] [--skip-tables=<tables>] [--skip-columns=<columns>] [--include-columns=<columns>] [--precise] [--recurse-objects] [--verbose] [--regex] [--regex-flags=<regex-flags>] [--regex-delimiter=<regex-delimiter>] [--regex-limit=<regex-limit>] [--format=<format>] [--report] [--report-changed-only] [--log[=<file>]] [--before_context=<num>] [--after_context=<num>]
13+
wp search-replace [<old>] [<new>] [<table>...] [--old=<value>] [--new=<value>] [--dry-run] [--network] [--all-tables-with-prefix] [--all-tables] [--export[=<file>]] [--export_insert_size=<rows>] [--skip-tables=<tables>] [--skip-columns=<columns>] [--include-columns=<columns>] [--precise] [--recurse-objects] [--verbose] [--regex] [--regex-flags=<regex-flags>] [--regex-delimiter=<regex-delimiter>] [--regex-limit=<regex-limit>] [--format=<format>] [--report] [--report-changed-only] [--log[=<file>]] [--before_context=<num>] [--after_context=<num>]
1414
~~~
1515

1616
Searches through all rows in a selection of tables and replaces
@@ -25,16 +25,24 @@ change primary key values.
2525

2626
**OPTIONS**
2727

28-
<old>
28+
[<old>]
2929
A string to search for within the database.
3030

31-
<new>
31+
[<new>]
3232
Replace instances of the first string with this new string.
3333

3434
[<table>...]
3535
List of database tables to restrict the replacement to. Wildcards are
3636
supported, e.g. `'wp_*options'` or `'wp_post*'`.
3737

38+
[--old=<value>]
39+
An alternative way to specify the search string. Use this when the
40+
search string starts with '--' (e.g., --old='--some-text').
41+
42+
[--new=<value>]
43+
An alternative way to specify the replacement string. Use this when the
44+
replacement string starts with '--' (e.g., --new='--other-text').
45+
3846
[--dry-run]
3947
Run the entire search/replace operation and show report, but don't save
4048
changes to the database.
@@ -139,6 +147,9 @@ change primary key values.
139147
# Search/replace to a SQL file without transforming the database
140148
$ wp search-replace foo bar --export=database.sql
141149

150+
# Search/replace string containing hyphens
151+
$ wp search-replace --old='--old-string' --new='new-string'
152+
142153
# Bash script: Search/replace production to development url (multisite compatible)
143154
#!/bin/bash
144155
if $(wp --url=http://example.com core is-installed --network); then

src/Search_Replace_Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ class Search_Replace_Command extends WP_CLI_Command {
134134
*
135135
* ## OPTIONS
136136
*
137-
* <old>
137+
* [<old>]
138138
* : A string to search for within the database.
139139
*
140-
* <new>
140+
* [<new>]
141141
* : Replace instances of the first string with this new string.
142142
*
143143
* [<table>...]

0 commit comments

Comments
 (0)