Skip to content

Commit 5c8bd84

Browse files
Copilotswissspidy
andcommitted
Improve YAML output formatting for execute command
Co-authored-by: swissspidy <[email protected]>
1 parent 1f2a6dc commit 5c8bd84

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Ability_Command.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,14 @@ public function execute( $args, $assoc_args ) {
320320
if ( 'json' === $format ) {
321321
WP_CLI::line( wp_json_encode( $result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) );
322322
} elseif ( 'yaml' === $format ) {
323-
WP_CLI::line( WP_CLI\Utils\mustache_render( '{{#.}}{{key}}: {{value}}{{/.}}', $result ) );
323+
// Convert to YAML-like output
324+
foreach ( $result as $key => $value ) {
325+
if ( is_array( $value ) || is_object( $value ) ) {
326+
WP_CLI::line( $key . ': ' . wp_json_encode( $value ) );
327+
} else {
328+
WP_CLI::line( $key . ': ' . $value );
329+
}
330+
}
324331
}
325332

326333
WP_CLI::success( 'Ability executed successfully.' );

0 commit comments

Comments
 (0)