Closed mklepaczewski closed 1 year ago
Thanks for the request, @mklepaczewski !
I propose to add
--use-require
flag toeval-file
to indicate that the script should be executed usingrequire()
.
Given the limitations you've described, your proposal seems reasonable.
Here's where wp eval-file
switched from include( $file )
to eval()
: https://github.com/wp-cli/eval-command/pull/21
Let's restore include( $file )
as an option, instead of using require()
.
@danielbachhuber I'll start working on it! Can you assign it to me, please? Thanks!
@danielbachhuber I have a question on this issue:
The eval command handles two scenarios:
include
takes a file path as an input, so the --use-require
makes sense in the first case.
How we should handle the STDIN?
Let's say for example something like:
cat script.php | wp eval-file - x y z --skip-wordpress --use-require
include
takes a file path as an input, so the--use-require
makes sense in the first case. How we should handle the STDIN?
@kozer If the user provides wp eval-file --use-include -
, then the command should call WP_CLI::error()
and explain that both arguments can't be used at the same time.
Feature Request
Describe your use case and the problem you are facing
eval-file
useseval()
to execute code in provided script. Unfortunately, this has some limitations:declare(strict_types=1)
in the script file throws a fatal error ineval()
Describe the solution you'd like
I propose to add
--use-require
flag toeval-file
to indicate that the script should be executed usingrequire()
.If the proposal is accepted I'm willing to implement it.