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

Consolidate to one standard approach for running WP-CLI commands from within commands #3139

Closed
danielbachhuber opened this issue Jul 11, 2016 · 1 comment
Assignees
Milestone

Comments

@danielbachhuber
Copy link
Member

Currently, we have two different ways of running new WP-CLI commands from within an existing command:

  • WP_CLI::launch_self() - launches a new process while reusing some runtime args and env variables, but not all.
  • WP_CLI::run_command() - calls the WP-CLI command using the existing process.

It's confusing to use these methods within a WP-CLI command, so I still end up writing my own implementation (e.g. wp-cli/restful@778c3e0#diff-157c802629de9f14607866f958873927R209)

It would be nice to have a WP_CLI::run_command() which:

  • Accepted the command as a string (e.g. 'rest post list --format=json'), because this is the most intuitive way for a developer to define the argument. These passed arguments would be automatically shell escaped, so the caller didn't have to worry about it.
  • Supported launching a new process, or running the command within the existing process. If a new process was launched, then the method would appropriately recycle our environment variables.
  • Either displayed the result of the command (Use proc_open() instead of passthru() to persist TTY mode #3117), or captured and returned the result of the execution.
@aaemnnosttv
Copy link
Contributor

This seems like the way to go, as both launch_self and run_command didn't work for me and I was more/less forced to reimplement this based on what you did in the rest diff command there.

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

2 participants