#!/usr/bin/perl

use strict;
use warnings;

use EMBOSS::ACD;

use Getopt::Long;
use Pod::Usage;
use Data::Dumper;
use XML::Simple;

my $output = "";
GetOptions(
	"output=s" => \$output
) or pod2usage();
@ARGV or pod2usage();

for (@ARGV) {
	eval {
		my $acd = EMBOSS::ACD->new($_);
		if ($output =~ /xml/i) {
			print XMLout($acd->{tree}, RootName => 'acd');
		} elsif ($output =~ /perl/i) {
			print Data::Dumper->Dump([$acd->{tree}], ["acd"]);
		}
	};
	warn $@ if $@;
}

=head1 NAME

acdcheck

=head1 AUTHOR

Luke McCarthy <lukem@gene.pbi.nrc.ca>

=head1 SYNOPSIS

acdcheck
[ --output FORMAT ]
FILE [ FILE ... ]

=head1 DESCRIPTION

Reads one or more named input FILEs and attempts to parse them as if they were
EMBOSS ACD (AJAX Command Definition) files.

=head1 OPTIONS

=over4

=item --output FORMAT

Upon successful parsing of each ACD file, print a representation of the parse
tree to standard output in the specified format.  FORMAT must be one of either
'XML' or 'Perl' (case-insensitive and without the quotes.)

=head1 COPYRIGHT

Copyright (c) 2004 Luke McCarthy.  All rights reserved.  This program is free
software.  You may copy or redistribute it under the same terms as Perl itself.
