2022-07-13 16:09:07 +00:00
|
|
|
package App::Changelord;
|
|
|
|
|
|
|
|
use 5.36.0;
|
|
|
|
|
|
|
|
use Moo;
|
|
|
|
use CLI::Osprey;
|
|
|
|
use YAML;
|
|
|
|
|
|
|
|
option source => (
|
|
|
|
is => 'ro',
|
2022-07-13 17:18:13 +00:00
|
|
|
doc => 'changelog yaml file',
|
2022-07-13 16:09:07 +00:00
|
|
|
default => 'CHANGELOG.yml',
|
|
|
|
);
|
|
|
|
|
2022-07-13 17:18:13 +00:00
|
|
|
has changelog => (
|
2022-07-13 16:09:07 +00:00
|
|
|
lazy => 1,
|
|
|
|
is => 'ro',
|
|
|
|
default => sub($self) {
|
|
|
|
return YAML::LoadFile($self->source)
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
sub as_markdown($self) {
|
|
|
|
my $changelog = $self->changelog;
|
|
|
|
|
|
|
|
my $output = "# Changelog";
|
|
|
|
|
|
|
|
$output .= " for " . $changelog->{project}{name}
|
|
|
|
if $changelog->{project}{name};
|
|
|
|
|
|
|
|
$output .= "\n\n";
|
|
|
|
|
|
|
|
my $n = 0;
|
|
|
|
$output .= join "\n", map { $self->render_release($_, $n++) } $changelog->{releases}->@*;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub render_release($self, $release, $n=0) {
|
|
|
|
|
|
|
|
# it's a string? Okay then!
|
|
|
|
return $release unless ref $release;
|
|
|
|
|
|
|
|
|
|
|
|
my $version = $release->{version} || ( $n ? '???' : 'NEXT' );
|
|
|
|
my $date = $release->{date};
|
|
|
|
|
|
|
|
my $output = '';
|
|
|
|
|
|
|
|
$output .= "## $version";
|
|
|
|
$output .= " ($date)" if $date;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub run($self) {
|
|
|
|
no warnings 'utf8';
|
|
|
|
print $self->as_markdown;
|
|
|
|
}
|
|
|
|
|
2022-07-13 17:18:13 +00:00
|
|
|
subcommand 'schema' => 'App::Changelord::Command::Schema';
|
2022-07-13 18:03:40 +00:00
|
|
|
subcommand 'validate' => 'App::Changelord::Command::Validate';
|
2022-07-13 17:18:13 +00:00
|
|
|
|
2022-07-13 16:09:07 +00:00
|
|
|
'end of App::Changeman';
|