8000 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
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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 #5980

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

Open
matiasbenedetto opened this issue Sep 9, 2024 · 1 comment

Comments

@matiasbenedetto
Copy link
Contributor
matiasbenedetto commented Sep 9, 2024

What?

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.

Reference:

wp-cli/php/class-wp-cli.php

Lines 731 to 745 in a177d5a

/**
* 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
*/
public static function line( $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.

There could be cases where something should be printed no matter if --quiet is set. Example by @ernilambar WordPress/theme-check#458 (comment)

@karthick-murugan
Copy link
Contributor

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

  1. 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." );

  1. 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.

  1. 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?

467F
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0