]> git.donarmstrong.com Git - infobot.git/commitdiff
enhance cli with history, editing and doExit. install libterm-readline-gnu-perl or...
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 22 Nov 2002 07:47:30 +0000 (07:47 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 22 Nov 2002 07:47:30 +0000 (07:47 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@687 c11ca15a-4712-0410-83d8-924469b57eb5

src/interface.pl

index c94e926a02d5c51b25bc3f2220511728bb4c4848..c786b8379ac2c41dd5a708d9ca06fa883803c102 100644 (file)
@@ -26,14 +26,19 @@ sub cliloop {
     $addressed = 1;
     $msgType = 'public';
 
-    print ">>> ";
-    while (<STDIN>) {
+    # install libterm-readline-gnu-perl to get history support
+    use Term::ReadLine;
+    $term = new Term::ReadLine 'blootbot';
+    $prompt = "$who> ";
+    #$OUT = $term->OUT || STDOUT;
+    while ( defined ($_ = $term->readline($prompt)) ) {
        $orig{message} = $_;
        $message = $_;
        chomp $message;
+       last if ($message =~ m/^quit$/);
        $_ = &process() if $message;
-       print ">>> ";
     }
+    &doExit();
 }
 
 1;