Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #10 from perlpilot/search

Search
  • Loading branch information...
commit f0748e62984680d802b0122cc14c2799c01ccca0 2 parents ae46ebc + c57f79b
@tadzik authored
Showing with 18 additions and 1 deletion.
  1. +18 −1 bin/panda
View
19 bin/panda
@@ -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 {
@@ -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);
@@ -67,6 +79,9 @@ sub execute(Command $c, $panda, @args) {
when 'info' {
projectinfo($panda, @args);
}
+ when 'search' {
+ search-projects($panda, @args);
+ }
}
}
@@ -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]

0 comments on commit f0748e6

Please sign in to comment.
Something went wrong with that request. Please try again.