mediawiki report publishing
[scpubgit/System-Introspector-Report.git] / bin / system-introspector-report
1 #!/usr/bin/env perl
2 use strictures;
3 use Getopt::Long;
4 use Pod::Usage;
5 use Try::Tiny;
6 use System::Introspector::Report::Source;
7 use System::Introspector::Report::Config;
8
9 GetOptions(
10   's|storage=s' => \my $storage_dir,
11   'c|config=s'  => \my $config_file,
12   'r|report=s'  => \my @report_types,
13   'p|publish=s' => \my @publish_types,
14   'a|all'       => \my $all_reports,
15   'h|help'      => sub { pod2usage(0) },
16 ) or pod2usage(2);
17
18 die "$0 requires --storage (-s) to be specified\n"
19   unless defined $storage_dir;
20
21 die "$0 requires --config (-c) to be specified\n"
22   unless defined $storage_dir;
23
24 my $config = System::Introspector::Report::Config
25   ->new(config_file => $config_file);
26
27 my $source = System::Introspector::Report::Source
28   ->new_from_root($storage_dir);
29
30 my @types = $all_reports
31   ? $config->report_types
32   : map [$_, {}], @report_types;
33 my @reports = $source->generate(@types);
34
35 for my $publisher ($config->publishers(@publish_types)) {
36   try {
37     $publisher->publish(\@reports);
38   }
39   catch {
40     print "Error during publish: $_\n";
41   };
42 }
43
44 __END__
45
46 =head1 NAME
47
48 system-introspector-report - Generate System::Introspector reports
49
50 =cut