text
stringlengths
0
834k
my $n_current = $o->cache_set_current('query');
unless ($n_results and bounded(0, $n_current, $n_results - 1)) {
my $targ = $o->conf('target') or return ();
my $r = PPM::UI::query($targ, '*');
return () unless $r->ok;
$o->cache_set_add('query', '*', $r->result);
$o->cache_set_current('query', scalar($o->cache_sets('query')) - 1);
}
my @words = $o->line_parsed($line);
# If the previous word isn't a number or the command, stop.
return ()
if ($#words > 0 and
$words[$#words] !~ /^\d+/ and
$start == length($line) or
$#words > 1);
# This is the most optimistic list:
my @results = $o->cache_set('query');
my $npkgs = @results;
my @compls = (1 .. $npkgs);
# If the previous word is a number, return only other numbers:
return $o->completions($word, \@compls)
if ($words[$#words] =~ /^\d+/);
# Either a number or the names of the packages
push @compls, map { $_->name } @results;
return $o->completions($word, \@compls);
}
sub run_properties {
my $o = shift;
my @args = @_;
my $args = $args[0];
trace(1, ""PPM: properties @args\n"");
# Check for anything that looks like a query. If it does, send it
# to query instead.
my $query = $o->raw_args || join ' ', @args;
$query ||= '';
if ($query and not PPM::UI::is_pkg($args[0]) and not parse_range($query)) {
$o->inform(""Wildcards detected; using 'query' instead.\n"");
return $o->run('query', @_);
}
# No Args: describes current index of current result set, or 1.
my $n_results = $o->cache_sets('query');
my $n_current = $o->cache_set_current('query');
my $ind = $o->cache_set_index('query');
unless (@args) {
unless ($n_results and bounded(0, $n_current, $n_results - 1)) {
$o->inform(""No query results to describe -- "" .
""use 'query' to find a package.\n"");
return;
}
else {
my @results = $o->cache_set('query');
my $npkgs = @results;
$o->inform(""$SEP\n"");
if (bounded(0, $ind, $npkgs-1)) {
my $n = $ind + 1;
$o->inform(""Package $n:\n"");
$o->describe_pkg($o->cache_entry('query', $ind));
}
else {
$o->inform(""Package 1:\n"");
$o->describe_pkg($results[0]);
$o->cache_set_index('query', 0);
}
$o->inform(""$SEP\n"");
}
}
# Args provided
else {
# Describe a particular number:
if (my @r = parse_range(@args)) {
unless ($n_results and bounded(0, $n_current, $n_results - 1)) {
$o->inform(""No query results to describe -- "" .
""use 'query' to find a package.\n"");
return;
}
else {
for my $n (@r) {
my @results = $o->cache_set('query');
my $npkgs = @results;
$o->inform(""$SEP\n"");
if (bounded(1, $n, $npkgs)) {
$o->inform(""Package $n:\n"");
$o->cache_set_index('query', $n-1);
my $old = $o->cache_entry('query');
my $prop =
PPM::UI::properties($o->conf('target'), $old->name);
unless ($prop->is_success) {
$o->warn($prop->msg);
next unless $prop->ok;
}
my ($pkg, $idate, $loc) = $prop->result_l;
$o->describe_pkg($pkg,