—#!/usr/bin/perl -w
use
strict;
use
warnings;
use
Getopt::Long;
GetOptions(
'help|h'
=> \
my
$help
,
'man|m'
=> \
my
$man
,
'version|v'
=> \
my
$version
,
) or _pod2usage();
_pod2usage(
(
$man
? (
'-sections'
=>
'.+'
) : ()),
'-exitval'
=> 0,
)
if
$help
or
$man
;
if
(
$version
) {
File::Basename::basename($0),
' '
,
PGXN::Meta::Validator->VERSION, $/;
exit
;
}
my
$file
=
shift
or _pod2usage();
die
"$file is not a valid, readable filename\n"
unless
-r
$file
;
my
$pmv
= PGXN::Meta::Validator->load_file(
$file
);
if
(
$pmv
->is_valid) {
"$file is OK\n"
;
exit
;
}
"$file is invalid. Errors:\n "
,
join
(
"\n "
,
$pmv
->errors),
"\n"
;
exit
1;
sub
_pod2usage {
Pod::Usage::pod2usage(
'-verbose'
=> 99,
'-sections'
=>
'(?i:(Usage|Options))'
,
'-exitval'
=> 1,
'-input'
=> __FILE__,
@_
);
}
1;
__END__
=head1 Name
validate_pgxn_meta - Validate the structure of a PGXN F<META.json> file
=head1 Usage
validate_pgxn_meta META.json
=head1 Options
-h --help Print a usage statement and exit.
-M --man Print the complete documentation and exit.
-v --version Print the version number and exit.
=head1 Output
If F<META.json> valid, the output will be:
META.json is OK
If it's not valid, the output will look something like:
META.json is invalid. Errors:
Missing mandatory field, 'license' (license) [Validation: 1.0.0]
=head1 See Also
L<PGXN::Meta::Validator> is the class that does the actual validation, and may
be used programmatically.
=head1 Author
David E. Wheeler <david@kineticode.com>
=head1 Copyright and License
Copyright (c) 2011 David E. Wheeler. Some Rights Reserved.
This module is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.
=cut