text
stringlengths
0
834k
$o->warn(<<END);
Target names must be non-empty: '$newname' is not a valid name.
END
return;
}
my $oldname = $targets[$oldnum - 1];
my $ret = PPM::UI::target_rename($oldname, $newname);
$o->warn($ret->msg) unless $ret->ok;
$o->conf('target', $newname)
if $o->conf('target') eq $oldname;
@targets = PPM::UI::target_list()->result_l;
$targets = scalar @targets;
}
elsif (matches($cmd, ""s|et"")) {
my ($key, $value) = @rest;
if (defined $key and $key =~ /=/ and not defined $value) {
($key, $value) = split /=/, $key;
}
unless(defined($key) && $key) {
$o->warn(<<END);
You must specify what option to set. See 'help target'.
END
return;
}
unless(defined($value)) {
$o->warn(<<END);
You must provide a value for the option. See 'help target'.
END
return;
}
my $targ = $o->conf('target');
my %keys = map { @$_ }
PPM::UI::target_config_keys($targ)->result_l;
unless ($keys{$key}) {
$o->warn(""Invalid set key '$key'; these are the settable values:\n"");
$o->warn("" $_\n"") for (grep { $keys{$_} } keys %keys);
return;
}
my $ok = PPM::UI::target_config_set($targ, $key, $value);
unless ($ok->is_success) {
$o->warn($ok->msg);
return unless $ok->ok;
}
$o->inform(""Target attribute '$key' set to '$value'\n"");
return 1;
}
elsif (matches($cmd, ""d|escribe"")) {
my %opts = (exec => 1);
my $sel;
if (@rest) {
local @ARGV = @rest;
GetOptions(\%opts, 'exec!');
@rest = @ARGV;
}
if (@rest) {
$sel = $rest[0] =~ /^\d+$/ ? $rest[0] :
do {
my $n = find_index($rest[0], 1, @targets);
if ($n < 1) {
$o->warn(""No such target '$rest[0]'.\n"");
return;
};
$n;
};
unless(bounded(1, $sel, $targets)) {
$o->warn(""No such target number '$sel'.\n"");
}
}
else {
$sel = find_index($o->conf('target'), 1, @targets);
}
my $targ = $targets[$sel-1];
my (@keys, @vals);
my $res = $opts{exec}
? PPM::UI::target_info($targ)
: PPM::UI::target_raw_info($targ);
unless ($res->is_success) {
$o->warn($res->msg);
return unless $res->ok;
}
my %h = $res->result_h;
my @h = sort keys %h;
push @keys, @h;
push @vals, $h{$_} for @h;
if ($opts{exec}) {
for (PPM::UI::target_config_info($targ)->result_l) {
push @keys, $_->[0];
push @vals, $_->[1];
}
}
$_ = ucfirst $_ for @keys;
$o->inform(""Describing target $sel ($targ):\n"");
$o->print_pairs(\@keys, \@vals);
return 1;
}
}
unless($targets) {
$o->warn(""No targets. Install a PPM target.\n"");
return;