text
stringlengths 0
834k
|
|---|
$row{size} = $size;
|
unless (defined $csv) {
|
$row{files} ||= ""-"" if $field{files};
|
$row{size} = ""-"" unless @files;
|
}
|
}
|
else {
|
$row{files} = $area->package_files($row{id});
|
$row{files} ||= ""-"" unless defined $csv;
|
}
|
}
|
$row{area} = $area->name if $field{area};
|
delete $row{id} unless $field{id};
|
$tab->add_row(\%row);
|
}
|
}
|
$tab->sort(sub ($$) { my($a, $b) = @_; $a->[0] cmp $b->[0]})
|
if @areas > 1 && $tab->can(""sort"");
|
if (defined $csv) {
|
$csv = "","" if $csv eq """";
|
print $tab->as_csv(null => """", field_separator => $csv, show_header => $show_header);
|
}
|
elsif (my $rows = $tab->rows) {
|
print $tab->as_box(null => """", show_trailer => 0, show_header => $show_header, align => {files => ""right"", size => ""right""}, box_chars => $BOX_CHARS, max_width => terminal_width());
|
if (1) {
|
my $s = ($rows == 1) ? """" : ""s"";
|
print "" ($rows package$s installed$in$matching)\n"";
|
}
|
}
|
else {
|
NO_PKG_INSTALLED:
|
print STDERR ""*** no packages installed$in$matching ***\n"";
|
}
|
}
|
}
|
sub glob2re {
|
my $glob = shift;
|
$glob = ""*$glob*"" unless $glob =~ /[*?]/;
|
my $re = quotemeta($glob);
|
$re =~ s/\\\?/./g;
|
$re =~ s/\\\*/.*/g;
|
$re = ""^$re\\z"";
|
$re =~ s/^\^\.\*//;
|
$re =~ s/\.\*\\z\z//;
|
return ""(?i:$re)"";
|
}
|
sub terminal_width {
|
require Term::ReadKey;
|
my($w) = -t STDOUT ? Term::ReadKey::GetTerminalSize() : 80;
|
$w ||= 80;
|
$w-- if $^O eq ""MSWin32""; # can't print on last column
|
$w;
|
}
|
sub do_query {
|
$USAGE = ""query <pattern>"";
|
usage() unless @ARGV == 1;
|
@ARGV = (""--matching"", @ARGV, ""--fields"", ""name,version,abstract,area"");
|
return do_list();
|
}
|
sub do_files {
|
$USAGE = ""files <pkg>"";
|
usage() unless @ARGV == 1;
|
my $pkg = shift(@ARGV);
|
my $foundit;
|
for my $area (map $ppm->area($_), $ppm->areas) {
|
next unless $area->initialized;
|
my $id = $area->package_id($pkg, sloppy => 1);
|
next unless defined($id);
|
$foundit++;
|
print ""$_\n"" for $area->package_files($id);
|
}
|
not_installed($pkg) unless $foundit;
|
}
|
sub not_installed {
|
my $pkg = shift;
|
die ""Package '$pkg' is not installed"";
|
}
|
sub do_verify {
|
my %opt;
|
if (@ARGV) {
|
$USAGE = ""verify [--verbose] [<package>]"";
|
require Getopt::Long;
|
Getopt::Long::GetOptions(\%opt,
|
'verbose',
|
) || usage();
|
$opt{package} = shift(@ARGV) if @ARGV;
|
usage() if @ARGV;
|
}
|
my @areas = grep $_->initialized, map $ppm->area($_), $ppm->areas;
|
if ($opt{package}) {
|
@areas = grep $_->package_id($opt{package}), @areas;
|
not_installed($opt{package}) unless @areas;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.