diff options
author | Nicolas Vigier <boklm@mageia.org> | 2013-06-13 12:44:40 +0000 |
---|---|---|
committer | Nicolas Vigier <boklm@mageia.org> | 2013-06-13 12:44:40 +0000 |
commit | 434f175a6afea9241473bbee01a84d990fab5ab8 (patch) | |
tree | 8e6f388e8af75748a2d40bb96368679ee4de67b7 /mgaadv | |
parent | f1b8824ce8bac223c86cf6040ad7b26b49fe6c3a (diff) | |
download | mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.tar mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.tar.gz mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.tar.bz2 mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.tar.xz mgaadvisories-434f175a6afea9241473bbee01a84d990fab5ab8.zip |
mgaadv: add support for multiple actions
Diffstat (limited to 'mgaadv')
-rwxr-xr-x | mgaadv | 53 |
1 files changed, 45 insertions, 8 deletions
@@ -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); |