text
stringlengths
0
834k
use Getopt::Long;
# These must come _after_ the options parsing.
require PPM::UI;
require PPM::Trace;
PPM::Trace->import(qw(trace));
my $NAME = q{PPM - Programmer's Package Manager};
my $SHORT_NAME = q{PPM};
our $VERSION = '3.1';
sub dictsort(@);
#=============================================================================
# Output Methods
#
# PPM behaves differently under different calling circumstances. Here are the
# various classes of messages it prints out:
# 1. error/warning - an error or ""bad thing"" has occurred
# 2. informational - required information like search results
# 3. verbose - verbose that's only needed in interactive mode
#
# Here are the cases:
# 1. PPM is in interactive mode: everything gets printed.
# 2. PPM is in batch mode: everything minus 'verbose' gets printed.
#=============================================================================
sub error {
my $o = shift;
return 1 unless $o->{SHELL}{output}{error};
CORE::print STDERR @_;
}
sub errorf {
my $o = shift;
return 1 unless $o->{SHELL}{output}{error};
CORE::printf STDERR @_;
}
sub warn { goto &error }
sub warnf { goto &errorf }
sub inform {
my $o = shift;
return 1 unless $o->{SHELL}{output}{inform};
CORE::print @_;
}
sub informf {
my $o = shift;
return 1 unless $o->{SHELL}{output}{inform};
CORE::printf @_;
}
sub verbose {
my $o = shift;
return 1 unless $o->{SHELL}{output}{verbose};
CORE::print @_;
}
sub verbosef {
my $o = shift;
return 1 unless $o->{SHELL}{output}{verbose};
CORE::printf @_;
}
sub assertw {
my $o = shift;
my $cond = shift;
my $msg = shift;
$o->warn(""Warning: $msg\n"") unless $cond;
return $cond;
}
sub assert {
my $o = shift;
my $cond = shift;
my $msg = shift;
$o->error(""Error: $msg\n"") unless $cond;
return $cond;
}
sub mode {
my $o = shift;
$o->{SHELL}{mode};
}
sub setmode {
my $o = shift;
my $newmode = shift || '';
my $oldmode = $o->{SHELL}{mode};
if ($newmode eq 'SHELL') {
$o->{SHELL}{output}{error} = 1;
$o->{SHELL}{output}{inform} = 1;
$o->{SHELL}{output}{verbose} = 1;
}
elsif ($newmode eq 'BATCH') {
$o->{SHELL}{output}{error} = 1;
$o->{SHELL}{output}{inform} = 1;
$o->{SHELL}{output}{verbose} = 0;
}
elsif ($newmode eq 'SCRIPT') {
$o->{SHELL}{output}{error} = 1;
$o->{SHELL}{output}{inform} = 1;
$o->{SHELL}{output}{verbose} = 0;
}
elsif ($newmode eq 'SILENT') {
$o->{SHELL}{output}{error} = 1;
$o->{SHELL}{output}{inform} = 0;
$o->{SHELL}{output}{verbose} = 0;