A WP-CLI command with a –format=json output nobody asked for

A custom command built with a table output, and a pipeline that needed to parse it.

WP_CLI::add_command( 'td orders stuck', function ( $args, $assoc ) {
    $rows = turkerdev_stuck_orders();

    WP_CLIUtilsformat_items(
        $assoc['format'] ?? 'table',
        $rows,
        array( 'id', 'status', 'stuck_since' )
    );
} );

format_items gives table, CSV, JSON, YAML and count from one call, which is the difference between a command a human runs and a command a script consumes. The monitoring check that needed it had been parsing the table output with awk for a year, and broke when a column was widened.