[Bps-public-commit] r15043 - in Prophet/branches/restyserver: .
jesse at bestpractical.com
jesse at bestpractical.com
Tue Aug 12 07:10:55 EDT 2008
Author: jesse
Date: Tue Aug 12 07:10:54 2008
New Revision: 15043
Modified:
Prophet/branches/restyserver/ (props changed)
Prophet/branches/restyserver/Makefile.PL
Prophet/branches/restyserver/lib/Prophet/CLI/Command/Shell.pm
Log:
r43065 at PC0169: jesse | 2008-08-12 11:56:15 +0100
r43048 at PC0169 (orig r15020): sartak | 2008-08-12 00:01:35 +0100
r69246 at onn: sartak | 2008-08-11 19:01:28 -0400
Use Term::ReadLine for prophet's shell so it's not torturous
Modified: Prophet/branches/restyserver/Makefile.PL
==============================================================================
--- Prophet/branches/restyserver/Makefile.PL (original)
+++ Prophet/branches/restyserver/Makefile.PL Tue Aug 12 07:10:54 2008
@@ -25,6 +25,10 @@
requires('XML::Atom::SimpleFeed');
features(
+ 'Prophet shell' => [
+ -default => 1,
+ 'Term::ReadLine',
+ ],
'Web server' => [
-default => 1,
'HTTP::Server::Simple', # HTTP::Server::Simple::CGI
@@ -55,7 +59,6 @@
-default => 0,
'Net::Bonjour',
],
-
);
all_from('lib/Prophet.pm');
Modified: Prophet/branches/restyserver/lib/Prophet/CLI/Command/Shell.pm
==============================================================================
--- Prophet/branches/restyserver/lib/Prophet/CLI/Command/Shell.pm (original)
+++ Prophet/branches/restyserver/lib/Prophet/CLI/Command/Shell.pm Tue Aug 12 07:10:54 2008
@@ -4,9 +4,26 @@
extends 'Prophet::CLI::Command';
use Path::Class 'file';
+has name => (
+ is => 'ro',
+ isa => 'Str',
+ default => sub { file($0)->basename },
+);
+
+has term => (
+ is => 'ro',
+ isa => 'Term::ReadLine',
+ lazy => 1,
+ handles => [qw/readline addhistory/],
+ default => sub {
+ require Term::ReadLine;
+ return Term::ReadLine->new("Prophet shell");
+ },
+);
+
sub prompt {
- my $binary = file($0)->basename;
- return "$binary> ";
+ my $self = shift;
+ return $self->name . '> ';
}
sub run {
@@ -15,12 +32,9 @@
local $| = 1;
$self->cli->interactive_shell(1);
- while (1) {
- print $self->prompt;
- my $input = <>;
- last if !defined($input);
-
- local @ARGV = split ' ', $input;
+ while (defined(local $_ = $self->readline($self->prompt))) {
+ next if /^\s*$/;
+ local @ARGV = split ' ', $_;
eval { $self->run_one_command };
warn $@ if $@;
}
More information about the Bps-public-commit
mailing list