add --no-next for prod render

This commit is contained in:
Yanick Champoux 2022-07-25 11:32:27 -04:00
parent dcc2f7192c
commit d555b10db9
2 changed files with 17 additions and 3 deletions

View File

@ -9,6 +9,9 @@ use CLI::Osprey
Render the full changelog. The default is to render the changelog Render the full changelog. The default is to render the changelog
in markdow, but the option C<--json> can be used to have a JSON in markdow, but the option C<--json> can be used to have a JSON
version instead. version instead.
To generate the changelog without the NEXT release, uses the
C<--no-next> option.
END END
with 'App::Changelord::Role::Changelog'; with 'App::Changelord::Role::Changelog';
@ -21,9 +24,16 @@ option json => (
doc => 'output schema as json', doc => 'output schema as json',
); );
option next => (
is => 'ro',
default => 1,
negatable => 1,
doc => 'include the NEXT release. Defaults to true.',
);
sub run($self) { sub run($self) {
no warnings 'utf8'; no warnings 'utf8';
print $self->as_markdown; print $self->as_markdown( $self->next );
} }
'end of App::Changelog::Command::Print'; 'end of App::Changelog::Command::Print';

View File

@ -40,14 +40,18 @@ sub render_refs ( $self, %links ) {
return $output . "\n"; return $output . "\n";
} }
sub as_markdown ($self) { sub as_markdown ($self, $with_next = 1) {
my $changelog = $self->changelog; my $changelog = $self->changelog;
my $output = $self->render_header; my $output = $self->render_header;
my $n = 0; my $n = 0;
$output .= join "\n", $output .= join "\n",
map { $self->render_release( $_, $n++ ) } $changelog->{releases}->@*; map { $self->render_release( $_, $n++ ) }
grep {
$with_next ? 1 : ( $_->{version} && $_->version ne 'NEXT' )
}
$changelog->{releases}->@*;
return $output; return $output;
} }