#!/usr/bin/env perl

use 5.006002;

use strict;
use warnings;

use Date::Tolkien::Shire::Data qw{ __valid_date_class };
use Getopt::Long 2.25;
use Pod::Usage;

our $VERSION = '0.008';

my %opt;

GetOptions( \%opt,
    qw{ blib! },
    help => sub { pod2usage( { -verbose => 2 } ) },
    version	=> sub {
	print <<"EOD";
$0 version $VERSION
perl version $]
EOD
	exit;
    },
) and @ARGV or pod2usage( { -verbose => 0 } );

if ( $opt{blib} ) {
    require blib;
    blib->import();
}

my $exit_status = 0;

foreach my $class ( @ARGV ) {
    eval {
	__valid_date_class( $class );
	print "$class OK\n";
	1;
    } or print $@;
}

exit( $exit_status > 250 ? 250 : $exit_status );

__END__

=head1 TITLE

valid-date-class - See whether a module can be used as a date class by __format().

=head1 SYNOPSIS

 valid-date-class Date::Tolkien::Shire
 valid-date-class -help
 valid-date-class -version

=head1 OPTIONS

=head2 -blib

If this Boolean option is asserted, the equivalent of C<use blib;> is
done before analyzing any modules speified.

=head2 -help

This option displays the documentation for this script. The script then
exits.

=head2 -version

This option displays the version of this script. The script then exits.

=head1 DETAILS

The L<Date::Tolkien::Shire::Data|Date::Tolkien::Shire::Data>
L<__format()|Date::Tolkien::Shire::Data/__format> subroutine will take
an object as its first argument, provided that object implements the
proper methods.

This Perl script takes as its arguments the names of one or more Perl
packages. Each package is loaded and checked to see if it has all the
required methods. If it does not, the missing methods are listed. If it
does, a success message it displayed.

The exit status is the number of packages that fail the test, or C<250>,
whichever is smaller.

=head1 AUTHOR

Thomas R. Wyant, III F<wyant at cpan dot org>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2017-2021 by Thomas R. Wyant, III

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl 5.10.0. For more details, see the full text
of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.

=cut

# ex: set textwidth=72 :
