Skip to content

Commit

Permalink
Add featured commands in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ernilambar committed Feb 28, 2024
1 parent 1742f66 commit 0e83a7e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/ScaffoldPackageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions templates/readme-using.mustache
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 0e83a7e

Please sign in to comment.