aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Vigier <boklm@mageia.org>2013-06-13 12:44:40 +0000
committerNicolas Vigier <boklm@mageia.org>2013-06-13 12:44:40 +0000
commit434f175a6afea9241473bbee01a84d990fab5ab8 (patch)
tree8e6f388e8af75748a2d40bb96368679ee4de67b7
parentf1b8824ce8bac223c86cf6040ad7b26b49fe6c3a (diff)
downloadmgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.tar
mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.tar.gz
mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.tar.bz2
mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.tar.xz
mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.zip
mgaadv: add support for multiple actions
-rwxr-xr-xmgaadv53
1 files changed, 45 insertions, 8 deletions
diff --git a/mgaadv b/mgaadv
index 7e3ec41..d40762c 100755
--- a/mgaadv
+++ b/mgaadv
@@ -3,12 +3,49 @@
use strict;
use MGA::Advisories;
-my %advdb;
-$advdb{advisories} = MGA::Advisories::get_advisories();
-MGA::Advisories::publish_advisories(\%advdb);
-MGA::Advisories::sort_advisories(\%advdb);
-MGA::Advisories::output_pages(\%advdb);
-MGA::Advisories::dumpdb(\%advdb);
-MGA::Advisories::send_adv_mail(\%advdb);
-MGA::Advisories::send_report_mail(\%advdb);
+my %actions = (
+ mksite => \&mksite,
+ usage => \&usage,
+);
+
+my %usage = (
+ mksite => <<END,
+$0 mksite
+
+Generates the advisories web site
+END
+ usage => <<END,
+$0 usage [action]
+
+Show action usage
+END
+);
+
+sub usage {
+ if ($_[1] && $usage{$_[1]}) {
+ print STDERR $usage{$_[1]};
+ } else {
+ print STDERR "$0 [action] [options]\n";
+ print STDERR "$0 usage [action]\n\n";
+ print STDERR "Available actions:\n";
+ print STDERR map { " - $_\n" } keys %actions;
+ }
+}
+
+sub mksite {
+ my %advdb;
+ $advdb{advisories} = MGA::Advisories::get_advisories();
+ MGA::Advisories::publish_advisories(\%advdb);
+ MGA::Advisories::sort_advisories(\%advdb);
+ MGA::Advisories::output_pages(\%advdb);
+ MGA::Advisories::dumpdb(\%advdb);
+ MGA::Advisories::send_adv_mail(\%advdb);
+ MGA::Advisories::send_report_mail(\%advdb);
+}
+
+if (@ARGV == 0 || !$actions{$ARGV[0]}) {
+ usage();
+ exit 1;
+}
+$actions{$ARGV[0]}->(@ARGV);