#!/usr/bin/perl

use strict;
use warnings;

use Carp qw(confess);
use Data::Dumper;
use Getopt::Std;

use Ernad::Announce;
use Ernad::Erimp;


my %o;

getopts("n", \%o);

my $file = $ARGV[0] // '';
if(not $file) {
  print "I neeed a file\n";
  exit;
}
if(not -f $file) {
  print "I can't open your file $file.";
  exit;
}

my $impna=&Ernad::Announce::get_impna_from_file($file);
if(not $impna) {
  print "I can't get the impna from $file\n";
  exit;
}
our $e=Ernad::Erimp->new({'impna' => $impna,
                          'verbose' => 10}) // '';
if(not $e) {
  print "I can't build an erimp for your file $file\n";
}

my $a=&Ernad::Announce::get($file);

print Dumper $a;

if(not $o{'n'}) {
  &Ernad::Announce::send_if_test($a);
}

exit;


### this has to be done when $e is defined
#my $i=&parse_report_list($in);
#my $i=&parse_report_list($out);
#exit;

## parse report list
#sub parse_report_list {
#  my $string=shift;
#  my $not=shift // '';
#  my $o;
#  foreach my $part (split(/,/,$string)) {
#    if(not defined($e->{'report'}->{$part})) {
#      confess "I don't know about the report $part";
#    }
#    ## check if we have not already mentioned that report
#    if($not->{$part}) {
#      print "You can't mention $part twice\n";
#      exit;
#    }
#    $o->{$part}=1;
#  }
#  return $o;
#}

