Introduce `WP_CLI_STRICT_ARGS_MODE` for dealing with arg ambiguity #3128

Merged
merged 1 commit into from Jul 8, 2016

Projects

None yet

1 participant

@danielbachhuber
Member

Consider a command like:

wp widget add rss sidebar-1 1 --url="http://wp-cli.org/feed/"

Historically, the --url=<url> parameter has been treated like a global
runtime argument, which has meant a command can't easily use it as its
own. Now, using the WP_CLI_STRICT_ARGS_MODE will tell WP-CLI to treat
any arguments before the command as global, and after the command as
local.

For instance:

WP_CLI_STRICT_ARGS_MODE=1 wp --url=wp.dev/site2 widget add rss sidebar-1 1
--url="http://wp-cli.org/feed/"

In this example, --url=wp.dev/site2 is the global argument, setting
WP-CLI to run against 'site2' on a WP multisite install.
--url="http://wp-cli.org/feed/" is the local argument, setting the RSS
feed widget with the proper URL.

I've thought long and hard about making a breaking change, and enforcing
strict args mode by default. At this point, I don't think it will ever
be worth it, given the majority use case isn't impacted by it, and it's
a better user experience to be able to supply arguments in an ambigious
order. When you need to be strict, you can use the environment variable.

Fixes #1222

@danielbachhuber danielbachhuber Introduce `WP_CLI_STRICT_ARGS_MODE` for dealing with arg ambiguity
Consider a command like:

```
wp widget add rss sidebar-1 1 --url="http://wp-cli.org/feed/"
```

Historically, the `--url=<url>` parameter has been treated like a global
runtime argument, which has meant a command can't easily use it as its
own. Now, using the `WP_CLI_STRICT_ARGS_MODE` will tell WP-CLI to treat
any arguments before the command as global, and after the command as
local.

For instance:

```
WP_CLI_STRICT_ARGS_MODE=1 wp --url=wp.dev/site2 widget add rss sidebar-1 1
--url="http://wp-cli.org/feed/"
```

In this example, `--url=wp.dev/site2` is the global argument, setting
WP-CLI to run against 'site2' on a WP multisite install.
`--url="http://wp-cli.org/feed/"` is the local argument, setting the RSS
feed widget with the proper URL.

I've thought long and hard about making a breaking change, and enforcing
strict args mode by default. At this point, I don't think it will ever
be worth it, given the majority use case isn't impacted by it, and it's
a better user experience to be able to supply arguments in an ambigious
order. When you need to be strict, you can use the environment variable.
0ab8115
@danielbachhuber danielbachhuber added this to the 0.24.0 milestone Jul 8, 2016
@danielbachhuber danielbachhuber merged commit 42cf7fb into master Jul 8, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@danielbachhuber danielbachhuber deleted the 1222-strict-args branch Jul 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment