diff options
Diffstat (limited to 'sbofind')
-rwxr-xr-x | sbofind | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -7,6 +7,7 @@ # # authors: Jacob Pipkin <j@dawnrazor.net> # Luke Williams <xocel@iquidus.org> +# Andreas Guldstrand <andreas.guldstrand@gmail.com> # license: WTFPL <http://sam.zoy.org/wtfpl/COPYING> use 5.16.0; @@ -18,7 +19,7 @@ use Getopt::Long qw(:config bundling); my $self = basename($0); -sub show_usage() { +sub show_usage { print <<EOF Usage: $self (search_term) @@ -50,17 +51,17 @@ GetOptions( 'queue|q' => \$show_queue, ); -show_usage and exit 0 if $help; -show_version and exit 0 if $vers; +show_usage() and exit 0 if $help; +show_version() and exit 0 if $vers; -show_usage and exit 1 unless exists $ARGV[0]; +show_usage() and exit 1 unless exists $ARGV[0]; my $search = $ARGV[0]; # if we can't find SLACKBUILDS.TXT in $config{HOME}, prompt to fetch the tree -slackbuilds_or_fetch; +slackbuilds_or_fetch(); # find anything with $search in its name -sub perform_search($) { +sub perform_search { exists $_[0] or script_error 'perform_search requires an argument.'; my $search = shift; my (@findings, $name, $found); @@ -86,10 +87,10 @@ sub perform_search($) { } # pull the contents of a file into a variable and format it for output -sub get_file_contents($) { +sub get_file_contents { exists $_[0] or script_error 'get_file_contents requires an argument'; -f $_[0] or return "$_[0] doesn't exist.\n"; - my ($fh, $exit) = open_read shift; + my ($fh, $exit) = open_read(shift); if ($exit) { warn $fh; return; @@ -103,24 +104,23 @@ sub get_file_contents($) { } # get build queue and return it as a single line. -sub show_build_queue($) { - exists $_[0] or script_error 'show_build_queue requires an argument.'; +sub show_build_queue { + exists $_[0] or script_error('show_build_queue requires an argument.'); my $queue = get_build_queue([shift], {}); return join(" ", reverse @$queue); } -my $findings = perform_search $search; +my $findings = perform_search($search); # pretty formatting if (exists $$findings[0]) { - my @listing = ("\n"); for my $hash (@$findings) { while (my ($key, $val) = each %$hash) { say "SBo: $key"; say "Path: $val"; - say "info: ". get_file_contents "$val/$key.info" if $show_info; - say "README: ". get_file_contents "$val/README" if $show_readme; - say "Queue: ". show_build_queue "$key" if $show_queue; + say "info: ". get_file_contents("$val/$key.info") if $show_info; + say "README: ". get_file_contents("$val/README") if $show_readme; + say "Queue: ". show_build_queue("$key") if $show_queue; say ''; } } |