New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce `WP_CLI_STRICT_ARGS_MODE` for dealing with arg ambiguity #3128

Merged
merged 1 commit into from Jul 8, 2016

Conversation

1 participant
@danielbachhuber
Member

danielbachhuber commented Jul 8, 2016

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

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.

@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