comparison src/luan/tools/CmdLine.java @ 117:e935581cf9fb

remove jline because the project moved to GitHub git-svn-id: https://luan-java.googlecode.com/svn/trunk@118 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 30 May 2014 08:57:24 +0000
parents 2428ecfed375
children 8d7730a5e3b4
comparison
equal deleted inserted replaced
116:1ff1c32417eb 117:e935581cf9fb
1 package luan.tools; 1 package luan.tools;
2 2
3 import java.io.Console;
3 import java.io.IOException; 4 import java.io.IOException;
4 import luan.lib.BasicLib; 5 import luan.lib.BasicLib;
5 import luan.Luan; 6 import luan.Luan;
6 import luan.LuanState; 7 import luan.LuanState;
7 import luan.LuanFunction; 8 import luan.LuanFunction;
8 import luan.LuanTable; 9 import luan.LuanTable;
9 import luan.LuanException; 10 import luan.LuanException;
10 import jline.ConsoleReader;
11 11
12 12
13 public class CmdLine { 13 public class CmdLine {
14 14
15 public static void main(String[] args) { 15 public static void main(String[] args) {
91 System.err.println(" - stop handling options and execute stdin"); 91 System.err.println(" - stop handling options and execute stdin");
92 System.exit(-1); 92 System.exit(-1);
93 } 93 }
94 94
95 static void interactive(LuanState luan) { 95 static void interactive(LuanState luan) {
96 try { 96 Console console = System.console();
97 ConsoleReader console = new ConsoleReader(); 97 LuanFunction print = (LuanFunction)luan.global().get("print");
98 console.setDefaultPrompt("> "); 98 while( true ) {
99 while( true ) { 99 String input = console.readLine("> ");
100 String input = console.readLine(); 100 if( input==null )
101 if( input==null ) 101 break;
102 break; 102 try {
103 try { 103 Object[] rtn = Luan.array(luan.eval(input,"stdin",true));
104 Object[] rtn = Luan.array(luan.eval(input,"stdin",true)); 104 if( rtn.length > 0 )
105 if( rtn.length > 0 ) 105 luan.JAVA.call(print,"print",rtn);
106 BasicLib.print(luan,rtn); 106 } catch(LuanException e) {
107 } catch(LuanException e) { 107 System.out.println(e.getMessage());
108 System.out.println(e.getMessage());
109 }
110 } 108 }
111 } catch(IOException e) {
112 throw new RuntimeException(e);
113 } 109 }
114 } 110 }
115 111
116 } 112 }