WP_CLI::line is the only method apart from error that's not muted by --quiet but is marked as just a retro-compat function · Issue #5980 · wp-cli/wp-cli · GitHub
More Web Proxy on the site http://driver.im/
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, there doesn't seem to be another function apart from WP_CLI::line() to log certain output that's not an error ( where WP_CLI:error() looks could be a better option ) using the --quiet parameter. All the other methods are muted using --quiet.
* Display informational message without prefix, and ignore `--quiet`.
*
* Message is written to STDOUT. `WP_CLI::log()` is typically recommended;
* `WP_CLI::line()` is included for historical compat.
*
* @access public
* @category Output
*
* @param string $message Message to display to the end user.
* @return null
*/
publicstaticfunctionline( $message = '' ) {
echo$message . "\n";
}
Why?
The problem is that this method's comment says it exists only for retro-compat purposes, this seems to signal that this could be deprecated in the future and it the only method able log something that not an error when running a command with --quiet.
Currently, WP_CLI::line() is the only method that allows output to be displayed even when the --quiet flag is used. However, since it is marked for retro-compatibility, there is a concern that it may be deprecated in the future. This raises the issue of how WP-CLI should handle cases where output needs to be displayed regardless of --quiet.
Possible Solutions
Introduce a New Method for Unmuted Logging
Create a function like WP_CLI::always_log() that behaves like WP_CLI::log(), but ignores --quiet.
WP_CLI::always_log( "Important message that should always appear." );
Modify WP_CLI::log() to Accept an Override Flag
Modify WP_CLI::log() to accept a second parameter ($force_output), which allows logging even when --quiet is enabled.
WP_CLI::log( "Important output", true ); // Force output even if --quiet is set.
Clarify the Role of WP_CLI::line()
Instead of deprecating WP_CLI::line(), formally acknowledge it as a method that bypasses --quiet for crucial outputs.
Would love to hear insights from the WP-CLI team on which approach would be best to move forward. Are there any concerns or alternative suggestions for handling this scenario?
What?
Currently, there doesn't seem to be another function apart from
WP_CLI::line()
to log certain output that's not an error ( whereWP_CLI:error()
looks could be a better option ) using the--quiet
parameter. All the other methods are muted using--quiet
.Reference:
wp-cli/php/class-wp-cli.php
Lines 731 to 745 in a177d5a
Why?
The problem is that this method's comment says it exists only for retro-compat purposes, this seems to signal that this could be deprecated in the future and it the only method able log something that not an error when running a command with
--quiet
.There could be cases where something should be printed no matter if
--quiet
is set. Example by @ernilambar WordPress/theme-check#458 (comment)The text was updated successfully, but these errors were encountered: