Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Search #10

Merged
merged 2 commits into from

3 participants

@perlpilot

This adds the ability to search name/description with regex. Example:

panda search ':i web'    # search for "web" case-insensitively

The output contains the module name, it's version and description.

@leto
Collaborator

Any possibility of getting a basic test for this?

@tadzik
Owner

Looks nice, merging.
Re testing this kind of stuff, I'm planning a major rework of the frontend of Panda, after it starts to work on nom. I'll probably make the executable testable too then.

@tadzik tadzik merged commit f0748e6 into tadzik:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
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]
Something went wrong with that request. Please try again.