aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Pipkin <d4wnr4z0r@yahoo.com>2012-05-30 11:10:46 -0500
committerJacob Pipkin <d4wnr4z0r@yahoo.com>2012-05-30 11:10:46 -0500
commit65eb542a3dcd027289c41afa25a4cea3f40eff10 (patch)
tree9edd4762b34222e2a99d8f34defb171eeb3ffb6c
parentc7af49421065f707e22db085b59191be74a99ad1 (diff)
downloadsbotools2-65eb542a3dcd027289c41afa25a4cea3f40eff10.tar.xz
add -r option to show README for any found slackbuilds
-rwxr-xr-xsbofind24
1 files changed, 17 insertions, 7 deletions
diff --git a/sbofind b/sbofind
index 07f5da4..67d2f75 100755
--- a/sbofind
+++ b/sbofind
@@ -24,6 +24,7 @@ Usage: $self (search_term)
Options:
-h: this screen.
-v: version information.
+ -r: show the README for each found item.
Example:
$self libsexy
@@ -32,11 +33,13 @@ EOF
}
my %options;
-getopts ('hv', \%options);
+getopts ('hvr', \%options);
show_usage () and exit (0) if (exists $options{h});
show_version () and exit (0) if (exists $options{v});
+my $show_readme = exists $options{r} ? 'TRUE' : 'FALSE';
+
show_usage () and exit (1) unless exists $ARGV[0];
my $search = $ARGV[0];
@@ -73,14 +76,21 @@ if (exists $findings[0]) {
my @listing;
for my $hash (@findings) {
while (my ($key, $value) = each %{$hash}) {
- push (@listing, "SBo: $key\n");
- push (@listing, "Path: $value\n\n");
+ push (@listing, "SBo: $key\n");
+ push (@listing, "Path: $value\n");
+ if ($show_readme eq 'TRUE') {
+ open my $fh, '<', "$value/README";
+ my $readme = do {local $/; <$fh>};
+ $readme =~ s/\n/\n /g;
+ push (@listing, "README: $readme");
+ close $readme;
+ }
+ push (@listing, "\n");
}
}
- my $tab = new Text::Tabulate();
- $tab->configure (tab => '\s');
- my $output = $tab->format (@listing);
- print "\n". $output;
+ for my $list (@listing) {
+ print $list;
+ }
} else {
print "Nothing found for search term: $search\n";
}