diff --git a/src/ScaffoldPackageCommand.php b/src/ScaffoldPackageCommand.php index f307bac..a8db913 100644 --- a/src/ScaffoldPackageCommand.php +++ b/src/ScaffoldPackageCommand.php @@ -248,6 +248,7 @@ public function package_readme( $args, $assoc_args ) { 'required_wp_cli_version' => ! empty( $composer_obj['require']['wp-cli/wp-cli'] ) ? str_replace( [ '~', '^', '>=' ], 'v', $composer_obj['require']['wp-cli/wp-cli'] ) : 'v1.3.0', 'shields' => '', 'has_commands' => false, + 'has_featured_commands' => false, 'wp_cli_update_to_instructions' => 'the latest stable release with `wp cli update`', 'show_powered_by' => isset( $composer_obj['extra']['readme']['show_powered_by'] ) ? (bool) $composer_obj['extra']['readme']['show_powered_by'] : true, ]; @@ -333,6 +334,18 @@ public function package_readme( $args, $assoc_args ) { $readme_args['has_multiple_commands'] = count( $readme_args['commands'] ) > 1; } + $readme_args['featured_commands'] = []; + + if ( ! empty( $composer_obj['extra']['featured-commands'] ) ) { + foreach ( $composer_obj['extra']['featured-commands'] as $command ) { + $readme_args['featured_commands'][] = [ + 'title' => "wp {$command}", + 'url' => '#' . str_replace( ' ', '-', "wp {$command}" ), + ]; + } + $readme_args['has_featured_commands'] = true; + } + if ( isset( $composer_obj['extra']['readme']['sections'] ) ) { $readme_section_headings = $composer_obj['extra']['readme']['sections']; } else { diff --git a/templates/readme-using.mustache b/templates/readme-using.mustache index 8751d82..22a6d50 100644 --- a/templates/readme-using.mustache +++ b/templates/readme-using.mustache @@ -1,4 +1,13 @@ {{#has_commands}} +{{#has_featured_commands}} + +**Featured Commands:** + +{{#featured_commands}} +- [{{title}}]({{url}}) +{{/featured_commands}} + +{{/has_featured_commands}} {{#has_multiple_commands}} This package implements the following commands: