-
-
Save b2gills/089854ad236635279ec7ff416e585f7a to your computer and use it in GitHub Desktop.
Search FreeBSD ports tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
unit class PortUtils::Search; | |
has IO::Path $.ports-dir; | |
has IO::Path @.cats; | |
method new() { | |
my $ports-dir = '/usr/ports/'.IO; | |
my IO::Path @cats; | |
my @check = $ports-dir; | |
while @check { | |
my $check = shift @check; | |
@check.append: @cats.append: $check.dir.grep: *.d | |
} | |
return self.bless( :$ports-dir, :@cats ); | |
} | |
proto method query ( \query ) {*} | |
multi method query ( Str \query ) { | |
@.cats.grep(*.basename.contains(query))».relative($.ports-dir) | |
} | |
multi method query ( Callable \query ) { # also handles Regex | |
@.cats.grep(query)».relative($.ports-dir) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment