diff options
author | Jacob Pipkin <j@dawnrazor.net> | 2012-08-31 15:53:21 -0500 |
---|---|---|
committer | Jacob Pipkin <j@dawnrazor.net> | 2012-08-31 15:53:21 -0500 |
commit | d55dbdf17977ed9b1dfd91c98a4a569960b851cd (patch) | |
tree | 8e6a860de9fe0e8f5e52bc71716f6b4d69241c6d /sbocheck | |
parent | 12a1c8c4530ddb9ab83fec1f9b5bf61a25764e6b (diff) | |
download | sbotools2-d55dbdf17977ed9b1dfd91c98a4a569960b851cd.tar.xz |
epic changes and fixes and much further testing
Diffstat (limited to 'sbocheck')
-rwxr-xr-x | sbocheck | 43 |
1 files changed, 27 insertions, 16 deletions
@@ -27,24 +27,35 @@ show_version && exit 0 if (exists $options{v}); update_tree; -print "Checking for updated SlackBuilds...\n"; -my $updates = get_available_updates; - -# pretty formatting. -my @listing; -for my $key (keys @$updates) { - my $string = "$$updates[$key]{name}-$$updates[$key]{installed}"; - $string .= " < needs updating (SBo has $$updates[$key]{update})\n"; - push @listing, $string; +# retrieve and format list of available updates +sub get_update_list () { + print "Checking for updated SlackBuilds...\n"; + my $updates = get_available_updates; + # pretty formatting. + my @listing; + for my $update (@$updates) { + my $string = "$$update{name}-$$update{installed}"; + $string .= " < needs updating (SBo has $$update{update})\n"; + push @listing, $string; + } + return \@listing; } -if (exists $listing[0]) { - my $tab = new Text::Tabulate (); - $tab->configure (tab => '\s'); - my $output = $tab->format (@listing); - say "\n". $output; -} else { - say "\nNo updates available."; +# Text::Tabulate and print list of updates +sub print_output ($) { + exists $_[0] or script_error 'print_output requires an argument'; + my $listing = shift; + if (exists $$listing[0]) { + my $tab = new Text::Tabulate (); + $tab->configure (tab => '\s'); + my $output = $tab->format (@$listing); + say "\n". $output; + } else { + say "\nNo updates available."; + } } +my $output = get_update_list; +print_output $output; + exit 0; |