node-wp-cli icon indicating copy to clipboard operation
node-wp-cli copied to clipboard

Error - option is required, but it isn't?

Open tdmalone opened this issue 9 years ago • 2 comments

When running the search_replace command, passing through two parameters - the old string to be replaced by the new string - I get this error:

.....\node_modules\wp-cli\lib\WP.js:90
throw "Error option <"+key+"> is required for "+use.join(" ")+". See http://wp-cli.org/commands/"+use.join('/');
^
Error option <export> is required for search-replace. See http://wp-cli.org/commands/search-replace

http://wp-cli.org/commands/search-replace shows that the only required arguments are the first two, and --export is indeed an optional argument.

Looking at the output of wp cli cmd-dump, the search-replace command appears to be explained like this:

"synopsis": "<old> <new> [<table>...] [--dry-run] [--network] [--all-tables-with-prefix] [--all-tables] [--export[=<file>]] [--export_insert_size=<rows>] [--skip-columns=<columns>] [--include-columns=<columns>] [--precise] [--recurse-objects] [--verbose] [--regex]"

I'm not certain, but could it be that because the option to include a file with the --export option is also optional, node-wp-cli is getting a bit confused about the status of this option?

tdmalone avatar Oct 06 '16 22:10 tdmalone

The same issue also occurs with the recent v1.4.0 of wp cli, where node-wp-cli wants the --log param to be provided to search_replace.

tdmalone avatar Oct 24 '17 23:10 tdmalone

+1 this problem.

var required = !/^\[[^\]]+\]$/.test(arg); The problem is that the regex triggers on the second [ in the field. https://regex101.com/tests

Krielkip avatar Mar 01 '18 13:03 Krielkip