--format parameter conflicts with core WP arguments
diablodale opened this issue · comments
--format is not a safe parameter name to use for diff or for generate.
Why?
Because format is a common name for arguments in core WP REST. Easy example is for posts.
Posts have a non-required argument "format" for the POST method endpoint like this:
"format": {
"required": false,
"enum": ["standard",
"aside",
"image",
"video",
"quote",
"link",
"gallery",
"audio"],
"description": "The format for the object.",
"type": "string"
}
I recommend to change everywhere this wp-cli --format parameter to something else.
I recommend "--outputformat" and it to be changed throughout the code, e.g. in generate, diff, get, list, ...
Oo, messy. It is throughout wp-cli itself. Unless one wants to break wp-cli users of --format (a larger set of users than restful), then I recommend a generic approach for conflicting parameters be used.
Perhaps there should be an auto generated blacklist for arguments of wp-cli, restful, and other packages.
Then this blacklist can be compared against the incoming set of arguments from REST endpoints.
Then change those that intersect.
One change could be to prepend title from the argument's schema and a colon or period. I prefer a colon. For example, in the conflict between the internal --format argument and the core WP rest post argument "format", the latter could be changed to:
- --post:format
- --post.format
Example:
wp rest post generate --format=progress --post:format=quote --title="My Title" --content="http://mysite.com"
Oo, messy. It is throughout wp-cli itself. Unless one wants to break wp-cli users of --format (a larger set of users than restful), then I recommend a generic approach for conflicting parameters be used.
I agree with this more generic approach idea, although I'm unsure of the specific implementation.
Somewhat related wp-cli/wp-cli#3128
Closing for now, as this project isn't under active development.