diff options
Diffstat (limited to 'mgaadv')
-rwxr-xr-x | mgaadv | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -2,9 +2,11 @@ use strict; use MGA::Advisories; +use Template; my %actions = ( mksite => \&mksite, + new => \&newadv, usage => \&usage, ); @@ -19,6 +21,12 @@ $0 usage [action] Show action usage END + new => <<END, +$0 new [type] [bugnum] + +Create a new advisory file. [type] should be security or bugfix and +[bugnum] is the bugzilla bug number. +END ); sub usage { @@ -31,6 +39,10 @@ sub usage { print STDERR map { " - $_\n" } keys %actions; } } +sub usageexit { + usage(@_); + exit 1; +} sub mksite { my %advdb; @@ -43,9 +55,18 @@ sub mksite { MGA::Advisories::send_report_mail(\%advdb); } +sub newadv { + usageexit('usage', $_[0]) unless @_ == 3; + my ($new, $type, $bugnum) = @_; + my $file = MGA::Advisories::newadv($type, $bugnum); + if ($file) { + my $editor = $ENV{EDITOR} || $ENV{VISUAL} || '/usr/bin/editor'; + system($editor, $file); + } +} + if (@ARGV == 0 || !$actions{$ARGV[0]}) { - usage(); - exit 1; + usageexit(); } $actions{$ARGV[0]}->(@ARGV); |