From 0268da9024bc8b59551929983c967f9c5aaf6b0c Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Thu, 13 Jun 2013 12:45:00 +0000 Subject: Add 'show' command to show an advisory --- NEWS | 1 + lib/MGA/Advisories.pm | 21 +++++++++++++++++++++ mgaadv | 17 +++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/NEWS b/NEWS index 3f62b51..16b8282 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ - add 'new' command to add a new advisory - add 'list' command to list advisories +- add 'show' command to show an advisory Version 0.4 diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm index f32625a..ac7a734 100644 --- a/lib/MGA/Advisories.pm +++ b/lib/MGA/Advisories.pm @@ -233,4 +233,25 @@ sub listadv { sort keys %{$advdb->{advisories}}; } +sub showadv { + my ($advdb, $adv) = @_; + if (!$advdb->{advisories}{$adv}) { + print STDERR "Cannot find advisory $adv\n"; + return undef; + } + my $template = Template->new( + INCLUDE_PATH => $config->{tmpl_dir}, + ); + my $vars = { + config => $config, + advisory => $adv, + advdb => $advdb, + basename => \%basename, + tools => \%tools, + }; + my $advtxt; + process_template($template, 'advisory', $vars, \$advtxt, 'txt'); + print $advtxt; +} + 1; diff --git a/mgaadv b/mgaadv index 4ea8b81..a2ad4de 100755 --- a/mgaadv +++ b/mgaadv @@ -31,6 +31,15 @@ $0 new [type] [bugnum] Create a new advisory file. [type] should be security or bugfix and [bugnum] is the bugzilla bug number. +END + }, + show => { + run => \&showadv, + descr => 'Show an advisory', + usage => < { @@ -87,6 +96,14 @@ sub listadv { MGA::Advisories::listadv(\%advdb); } +sub showadv { + usageexit('usage', $_[0]) unless @_ == 2; + my $adv = $_[1]; + my %advdb; + $advdb{advisories} = MGA::Advisories::get_advisories(); + MGA::Advisories::showadv(\%advdb, $adv); +} + if (@ARGV == 0 || !$actions{$ARGV[0]}) { usageexit(); } -- cgit v1.2.1