perlconsole
view release on metacpan or search on metacpan
lib/PerlConsole/Commands.pm view on Meta::CPAN
sub help
{
my ($class, $console, $topic) = @_;
if (! defined $topic) {
return "The following help topics are available:\n".
join("\n- ", keys%{$help});
}
else {
# preferences have automated online help
if ($topic =~ /preferences/) {
return $console->{'prefs'}->help();
}
elsif (grep /^$topic$/, $console->{'prefs'}->getPreferences()) {
return $console->{'prefs'}->help($topic);
}
elsif (defined $help->{$topic}) {
return $help->{$topic};
}
else {
return "No such help topic: $topic";
}
}
}
lib/PerlConsole/Console.pm view on Meta::CPAN
##############################################################
# Constructor
##############################################################
sub new($@)
{
my ($class, $version) = @_;
# the console's data structure
my $self = {
version => $version,
prefs => new PerlConsole::Preferences,
terminal => new Term::ReadLine("Perl Console"),
lexical_environment => new Lexical::Persistence,
rcfile => $ENV{HOME}.'/.perlconsolerc',
prompt => "Perl> ",
modules => {},
logs => [],
errors => [],
};
bless ($self, $class);
# set the readline history if a Gnu terminal
if ($self->{'terminal'}->ReadLine eq "Term::ReadLine::Gnu") {
$SIG{'INT'} = sub { $self->clean_exit(0) };
$self->{'terminal'}->ReadHistory($ENV{HOME} . "/.perlconsole_history");
}
# init the completion list with Perl internals...
$self->addCompletion([@perl_keywords]);
# ... and with PerlConsole's ones
$self->addCompletion([$self->{'prefs'}->getPreferences]);
foreach my $pref ($self->{'prefs'}->getPreferences) {
$self->addCompletion($self->{'prefs'}->getValidValues($pref));
}
# FIXME : we'll have to rewrite the commands stuff in a better way
$self->addCompletion([qw(:quit :set :help)]);
# the console's ready!
return $self;
}
# This is where we define all the options supported
# on the command-line
sub parse_options
lib/PerlConsole/Console.pm view on Meta::CPAN
}
##############################################################
# Preferences
##############################################################
# accessors for the encapsulated preference object
sub setPreference($$$)
{
my ($self, $pref, $value) = @_;
my $prefs = $self->{'prefs'};
$self->addLog("setPreference: $pref = $value");
return $prefs->set($pref, $value);
}
sub getPreference($$)
{
my ($self, $pref) = @_;
my $prefs = $self->{'prefs'};
my $val = $prefs->get($pref);
return $val;
}
# set the output and take care to load the appropriate module
# for the output
sub setOutput($$)
{
my ($self, $output) = @_;
my $rh_output_modules = {
'yaml' => 'YAML',
( run in 3.172 seconds using v1.01-cache-2.11-cpan-98e64b0badf )