Skip to content

Commit

Permalink
Merge pull request #10 from perlpilot/search
Browse files Browse the repository at this point in the history
Search
  • Loading branch information
Tadeusz Sośnierz committed Aug 29, 2011
2 parents ae46ebc + c57f79b commit f0748e6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion bin/panda
Expand Up @@ -3,7 +3,7 @@ use Shell::Command;
use Panda;

subset Command of Str where
'install' | 'list' | 'update' | 'info';
'install' | 'list' | 'update' | 'info' | 'search';

sub installprojects($panda, @args) {
for @args -> $x {
Expand All @@ -27,6 +27,18 @@ sub listprojects($panda) {
}
}

sub wrap ($str) {
return $str.comb(/ . ** 0..40 [ << | $ ]/).grep({ .chars > 0 }).join("\n" ~ " " x 36);
}

sub search-projects($panda, $string) {
for $panda.ecosystem.project-list -> $project {
my $p = $panda.ecosystem.get-project($project);
next unless $p.name ~~ / <$string> / || $p.metainfo<description> ~~ / <$string> /;
printf "%-24s %-10s %s\n",$p.name,$p.version, wrap($p.metainfo<description>);
}
}

sub projectinfo($panda, @args) {
for @args -> $p {
my $x = $panda.ecosystem.get-project($p);
Expand Down Expand Up @@ -67,6 +79,9 @@ sub execute(Command $c, $panda, @args) {
when 'info' {
projectinfo($panda, @args);
}
when 'search' {
search-projects($panda, @args);
}
}
}

Expand Down Expand Up @@ -119,6 +134,8 @@ Options:
Display this message and quit
install [module1 module2]
Install a modules(s)
search
Search module name/description using regex
list
List the available packages
info [module1 module2]
Expand Down

0 comments on commit f0748e6

Please sign in to comment.