[Bps-public-commit] r14282 - in Prophet/trunk: . lib/Prophet/CLI/Command

sartak at bestpractical.com sartak at bestpractical.com
Fri Jul 18 15:47:48 EDT 2008


Author: sartak
Date: Fri Jul 18 15:47:38 2008
New Revision: 14282

Added:
   Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm
Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI/Command.pm

Log:
 r64589 at onn:  sartak | 2008-07-18 15:47:20 -0400
 Add a "shell" command


Modified: Prophet/trunk/lib/Prophet/CLI/Command.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command.pm	Fri Jul 18 15:47:38 2008
@@ -8,7 +8,7 @@
     handles => [
         qw/args  set_arg  arg  has_arg  delete_arg/,
         qw/props set_prop prop has_prop delete_prop/,
-        'app_handle',
+        'app_handle', 'run_one_command',
     ],
 );
 

Added: Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm
==============================================================================
--- (empty file)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	Fri Jul 18 15:47:38 2008
@@ -0,0 +1,28 @@
+#!/usr/bin/env perl
+package Prophet::CLI::Command::Shell;
+use Moose;
+extends 'Prophet::CLI::Command';
+
+sub prompt { "prophet> " }
+
+sub run {
+    my $self = shift;
+
+    local $| = 1;
+
+    while (1) {
+        print $self->prompt;
+        my $input = <>;
+        last if !defined($input);
+
+        local @ARGV = split ' ', $input;
+        eval { $self->run_one_command };
+        warn $@ if $@;
+    }
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+



More information about the Bps-public-commit mailing list