Add `--hook=<hook>` flag to `eval` and `shell` to choose timing
Feature Request
For both the eval|eval-file commands as well as the shell command, there's a fixed point in time within the WordPress lifecycle that these are executed.
It would be great to have a --hook=<hook> flag for these that allows the user to postpone when they are being triggered, so that you can choose a specific time within the WordPress lifecycle to run them on.
- [x] Yes, I reviewed the contribution guidelines.
Describe your use case and the problem you are facing
An example is using these commands to QA new code. Some code can only be executed once the preconditions are met, which means they need to be executed at or after a certain action.
Allowing these commands to be attached to a specific action/filter allows the user to choose when to execute them, so that they can ensure the preconditions for the code to be run are met.
Describe the solution you'd like
This can probably be done by dynamically creating a closure with the code to evaluate or the PsySh breakpoint and attaching that closure to the requested action, instead of immediately executing something.