From: timriker Date: Fri, 22 Nov 2002 07:47:30 +0000 (+0000) Subject: enhance cli with history, editing and doExit. install libterm-readline-gnu-perl or... X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a8967ac34eb655cbe4822b579e6a0b834dc026f3;p=infobot.git enhance cli with history, editing and doExit. install libterm-readline-gnu-perl or get no readline enhancements git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@687 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/blootbot/src/interface.pl b/blootbot/src/interface.pl index c94e926..c786b83 100644 --- a/blootbot/src/interface.pl +++ b/blootbot/src/interface.pl @@ -26,14 +26,19 @@ sub cliloop { $addressed = 1; $msgType = 'public'; - print ">>> "; - while () { + # 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;