Skip to content
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

Terminus could throw an error when old-style wp-cli / drush parameter quoting is used. #1549

Open
danielbachhuber opened this issue Jan 23, 2017 · 2 comments

Comments

@danielbachhuber
Copy link
Contributor

When I try to run wp solr index via Terminus, I see this unexpected error:

 $ terminus wp solr-demo-redux.dev "solr index"
 [warning] This environment is in read-only Git mode. If you want to make changes to the codebase of this site (e.g. updating modules or plugins), you will need to toggle into read/write SFTP mode first.
Error: 'solr index' is not a registered wp command. See 'wp help'.
 [notice] Command: solr-demo-redux.dev -- 'wp '\''solr index'\''' [Exit: 1]
 [error]

When I run wp solr via Terminus, I see the expected result:

$ terminus wp solr-demo-redux.dev "solr"
 [warning] This environment is in read-only Git mode. If you want to make changes to the codebase of this site (e.g. updating modules or plugins), you will need to toggle into read/write SFTP mode first.
usage: wp solr check-server-settings
   or: wp solr delete [<id>...] [--all]
   or: wp solr index [--posts_per_page] [--post_type]
   or: wp solr info [--field=<field>] [--format=<format>]
   or: wp solr optimize-index
   or: wp solr repost-schema
   or: wp solr stats [--field=<field>] [--format=<format>]

See 'wp help solr <command>' for more information on a specific command.
 [notice] Command: solr-demo-redux.dev -- 'wp solr' [Exit: 0]

The nature of the original error message leads me to believe Terminus is incorrectly quoting WP-CLI subcommands.

If I run an incorrect WP-CLI subcommand, WP-CLI correctly interprets the parent as a valid command and the child as an invalid subcommand:

$ wp solr inde
Error: 'inde' is not a registered subcommand of 'solr'. See 'wp help solr'.

Therefore, Terminus must be calling wp 'solr index', which WP-CLI then interprets to be an invalid command.

@danielbachhuber
Copy link
Contributor Author

In the process of writing this issue, I came across one solution: terminus wp solr-demo-redux.dev -- solr index (#1517, #1505)

If this is the new preferred syntax, shouldn't terminus wp solr-demo-redux.dev "solr index" (e.g. no --) produce a Terminus error?

@greg-1-anderson
Copy link
Member

@danielbachhuber You are correct that using -- is the preferred syntax. Quoting is now used to pass a single parameter that contains spaces. This is a break from Terminus 0.x, and more in line with what other Symfony Console apps and other commandline tools use.

Terminus could, in fact, throw a helpful error message if the first parameter (the wp-cli command) contained a space. That's a good suggestion. Other parameters beyond the first may or may not contain spaces, though, so only the first parameter (after site.env) should be checked.

@greg-1-anderson greg-1-anderson changed the title Terminus incorrectly quotes WP-CLI subcommands Terminus could throw an error when old-style wp-cli / drush parameter quoting is used. Jan 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants