#!/usr/bin/env perl

use strict;
use warnings;
use Math::DifferenceSet::Planar;

use constant PDS => Math::DifferenceSet::Planar::;

$| = 1;

die "usage: show_databases [directory]" if @ARGV > 1 || grep {!-d} @ARGV;

if (@ARGV) {
    $Math::DifferenceSet::Planar::Data::DATABASE_DIR = $ARGV[0];
}

print "$Math::DifferenceSet::Planar::Data::DATABASE_DIR\n";
foreach my $db (PDS->list_databases) {
    my $count = eval { PDS->set_database($db) };
    if (defined $count) {
        my $min = PDS->iterate_available_sets->()->order;
        my $max = PDS->available_max_order;
        print "$db: $count sets, $min <= order <= $max\n";
    }
    else {
        print "$db: bad database\n";
    }
}

__END__
=head1 NAME

show_databases - show available planar difference set databases

=head1 SYNOPSIS

  show_databases [directory]

=head1 DESCRIPTION

This example program examines the distribution share directory, or its
optional directory argument, and reports databases found there, with a
short summary of their content.

The output is the name of the directory and a list of database names
with some of the database properties.  They are displayed in the order
they would be considered as a default database.

=head1 AUTHOR

Martin Becker, E<lt>becker-cpan-mp I<at> cozap.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2019 by Martin Becker, Blaubeuren.  All rights reserved.

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.10.0 or,
at your option, any later version of Perl 5 you may have available.

=head1 DISCLAIMER OF WARRANTY

This library 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
