text stringlengths 0 834k |
|---|
} |
} |
elsif (defined $num) { |
$o->warn(""Argument to '$args[0]' must be numeric; see 'help profile'.\n""); |
return; |
} |
else { |
$o->warn(""profile: invalid use of '$args[0]' command: see 'help profile'.\n""); |
return; |
} |
# Validate the new name: |
my $newprof = $args[2]; |
unless (defined $newprof and length($newprof)) { |
$newprof = '' unless defined $newprof; |
$o->warn(<<END); |
Profile names must be non-empty: '$newprof' is not a valid name. |
END |
return; |
} |
# Actually do it: |
my $ok = PPM::UI::profile_rename($oldprof, $newprof); |
unless ($ok->is_success) { |
$o->warn($ok->msg); |
return unless $ok->ok; |
} |
if ($profile eq $oldprof) { |
$profile = $newprof; |
PPM::UI::profile_set($profile); |
} |
@profiles = dictsort PPM::UI::profile_list()->result_l; |
} |
# Restore current profile: |
elsif (matches($args[0], ""res|tore"")) { |
unless (@profiles) { |
$o->warn(<<END); |
No profiles on this server. Use 'profile add' to add a profile. |
END |
return; |
} |
unless ($which >= 0) { |
$o->warn(<<END); |
No profile selected. Use 'profile <number>' to select a profile. |
END |
return; |
} |
my ($clean_packages, $dry) = (0, 0); |
my ($force, $follow) = (1, 0); |
{ |
local @ARGV = @args; |
GetOptions('clean!' => \$clean_packages, |
'force!' => \$force, |
'follow!' => \$follow, |
'dryrun' => \$dry, |
); |
@args = @ARGV; |
} |
my $cb_inst = $dry ? \&dr_install : \&cb_install; |
my $cb_rm = $dry ? \&dr_remove : \&cb_remove ; |
my $ok = PPM::UI::profile_restore($profile, sub {$o->$cb_inst(@_)}, |
sub {$o->$cb_rm(@_)}, $force, $follow, |
$dry, $clean_packages); |
if ($ok->ok) { |
$o->cache_clear('query'); |
$o->inform(""Profile '$profile' restored.\n""); |
} |
else { |
$o->warn($ok->msg); |
return; |
} |
return 1; |
} |
# Unrecognized subcommand: |
else { |
$o->warn(""No such profile command '$args[0]'; see 'help profile'.\n""); |
return; |
} |
} |
if (@profiles) { |
@profiles = dictsort @profiles; |
my $i = 0; |
$o->inform(""Profiles:\n""); |
my $profile = PPM::UI::profile_get()->result; |
for (@profiles) { |
$o->informf(""%s%2d"", $profile eq $profiles[$i] ? ""*"" : "" "", $i + 1); |
$o->inform("". $_\n""); |
$i++; |
} |
} |
elsif (defined $args[0] and matches($args[0], ""del|ete"")) { |
# assume that we just deleted the last profile |
$o->warn(<<END); |
Profile deleted; no remaining profiles on the server. |
END |
} |
else { |
$o->warn(<<END); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.