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

Provide a CLI option to run multiple commands in one process. #180

Open
1 task done
toddr opened this issue Sep 6, 2023 · 1 comment
Open
1 task done

Provide a CLI option to run multiple commands in one process. #180

toddr opened this issue Sep 6, 2023 · 1 comment

Comments

@toddr
Copy link

toddr commented Sep 6, 2023

Feature Request

Describe your use case and the problem you are facing

I would like a "multi" option that would allow me to run multiple CLI commands in one process, speeding up overall execution time.

Describe the solution you'd like

The option would use STDIN or possibly a data file that lists the commands we want to run all at once.

A draft idea might be something like this.

echo 'set options blogname "my title"' > commands.txt
echo 'set options blogdescription "my description"' >> commands.txt
echo 'core update' >> commands.txt
wp-cli --json runcommands << commands.txt

I'd also be open to some complex command line only option like this. The only problem with this is that CLI would have to convert the args into individual commands, splitting on space.

wp-cli --json multi 'set options blogname "my title"' 'set options blogdescription "my description"'  
'core update'

This command would come with a caveat emptor warning that each command may have unexpected side effects on the later commands and anyone using it needs to be certain that it won't affect them to run it all in one process without flush or refresh.

In my above example, I would be required to know that messing with blogname/description will not have side effects on each other and that the update would be fine following the first 2.

If we wanted to get fancy, maybe we'd add a flush option that would invalidate caches if needed as you go?

The JSON result might provide an array of responses from each command.

@danielbachhuber
Copy link
Member

Thanks for the suggestion, @toddr !

I think this would be best implemented as a standalone package first. It could be considered for including in WP-CLI proper once the real-world idiosyncrasies have been worked out.

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