CliOutput

Class.

use Saij\WpAppFramework\WpCli\CliOutput;

Output of a WP-CLI command: passed to a parameter of this type of a #[CliSubcommand] method.

Messages go through WP-CLI: log() and success() write to stdout, warning() to stderr; --quiet suppresses them. Errors are thrown as CliException.

Methods

log()

log(string $message): void

Prints the message as it is.

ParameterTypeDefaultDescription
messagestringrequiredThe text of the line.

success()

success(string $message): void

Prints Success: followed by the message.

ParameterTypeDefaultDescription
messagestringrequiredThe text after Success: .

table()

table(array $rows, array $fields): void

Prints the rows as table with the given columns.

ParameterTypeDefaultDescription
rowslist<array<string, scalar|null>>requiredThe rows, each an array of its values by column name.
fieldslist<string>requiredKeys of the rows to show, in this order.

warning()

warning(string $message): void

Prints Warning: followed by the message.

ParameterTypeDefaultDescription
messagestringrequiredThe text after Warning: .