Modified:
trunk/lib/Shell/Perl.pm
Log:
new instance variable/switch "ornaments" and fix to "quit" command
Modified: trunk/lib/Shell/Perl.pm
==============================================================================
--- trunk/lib/Shell/Perl.pm (original)
+++ trunk/lib/Shell/Perl.pm Fri Jul 27 07:33:22 2007
@@ -8,10 +8,10 @@
# /Id: Perl.pm 1131 2007-01-27 17:43:35Z me / # don't erase that for now
# $Id$
-our $VERSION = '0.0014';
+our $VERSION = '0.0015';
use base qw(Class::Accessor); # soon use base qw(Shell::Base);
-Shell::Perl->mk_accessors(qw(out_type dumper context package term )); # XXX use_strict
+Shell::Perl->mk_accessors(qw( out_type dumper context package term ornaments )); # XXX use_strict
use Term::ReadLine;
use Shell::Perl::Dumper;
@@ -26,7 +26,6 @@
my $self = shift;
my $sh = $self->SUPER::new({
context => 'list', # print context
- package => __PACKAGE__ . '::sandbox',
@_ });
$sh->_init;
return $sh;
@@ -58,6 +57,8 @@
} # XXX this is not working 100% - and I have no clue about it
}
+ $self->set_package( __PACKAGE__ . '::sandbox' );
+
}
sub _shell_name {
@@ -230,6 +231,7 @@
my $self = shift;
my $shell_name = _shell_name;
$self->term( my $term = Term::ReadLine->new($shell_name) );
+ $term->ornaments($self->ornaments); # XXX
my $prompt = "$shell_name > ";
print "Welcome to the Perl shell. Type ':help' for more information\n\n";
@@ -295,9 +297,17 @@
sub run_with_args {
- my $self = shift; #
- # XXX do something with @ARGV (GetOpt)
- my $shell = Shell::Perl->new();
+ my $self = shift;
+
+ # XXX do something with @ARGV (Getopt)
+ my %options = ( ornaments => 1 );
+ if ( @ARGV ) {
+ # only require Getopt::Long if there are actually command line arguments
+ require Getopt::Long;
+ Getopt::Long::GetOptions( \%options, 'ornaments!' );
+ }
+
+ my $shell = Shell::Perl->new(%options);
$shell->run;
}