add command validate
This commit is contained in:
parent
b63f061617
commit
1d32409f56
@ -59,5 +59,6 @@ sub run($self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
subcommand 'schema' => 'App::Changelord::Command::Schema';
|
subcommand 'schema' => 'App::Changelord::Command::Schema';
|
||||||
|
subcommand 'validate' => 'App::Changelord::Command::Validate';
|
||||||
|
|
||||||
'end of App::Changeman';
|
'end of App::Changeman';
|
||||||
|
39
lib/App/Changelord/Command/Validate.pm
Normal file
39
lib/App/Changelord/Command/Validate.pm
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package App::Changelord::Command::Validate;
|
||||||
|
|
||||||
|
use 5.36.0;
|
||||||
|
|
||||||
|
use Moo;
|
||||||
|
use CLI::Osprey;
|
||||||
|
|
||||||
|
use Path::Tiny;
|
||||||
|
use JSON;
|
||||||
|
use YAML::XS;
|
||||||
|
use JSON::Schema::Modern;
|
||||||
|
|
||||||
|
option json => (
|
||||||
|
is => 'ro',
|
||||||
|
default => 0,
|
||||||
|
doc => 'output schema as json',
|
||||||
|
);
|
||||||
|
|
||||||
|
sub run($self) {
|
||||||
|
local $YAML::XS::Boolean = 'boolean';
|
||||||
|
|
||||||
|
my $schema = path(__FILE__)->sibling('changelog-schema.yml')->slurp;
|
||||||
|
|
||||||
|
my $result = JSON::Schema::Modern->new(
|
||||||
|
output_format => 'detailed',
|
||||||
|
)->evaluate(
|
||||||
|
$self->parent_command->changelog,
|
||||||
|
YAML::XS::Load($schema),
|
||||||
|
);
|
||||||
|
|
||||||
|
return say "woo, changelog is valid!" if( $result eq 'valid' );
|
||||||
|
|
||||||
|
|
||||||
|
print $result;
|
||||||
|
die "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
'end of App::Changelog::Command::Validate';
|
Loading…
Reference in New Issue
Block a user