comparison src/luan/CmdLine.java @ 30:8d8f4f5caef4

minor git-svn-id: https://luan-java.googlecode.com/svn/trunk@31 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 07 Dec 2012 20:22:19 +0000
parents 9bc66d09ea48
children 5cf15507d77e
comparison
equal deleted inserted replaced
29:9bc66d09ea48 30:8d8f4f5caef4
18 if( args.length == 0 ) { 18 if( args.length == 0 ) {
19 interactive = true; 19 interactive = true;
20 showVersion = true; 20 showVersion = true;
21 } else { 21 } else {
22 while( i < args.length ) { 22 while( i < args.length ) {
23 String arg = args[i++]; 23 String arg = args[i];
24 if( !arg.startsWith("-") || arg.equals("--") ) 24 if( !arg.startsWith("-") || arg.equals("--") )
25 break; 25 break;
26 if( arg.equals("-i") ) { 26 if( arg.equals("-i") ) {
27 interactive = true; 27 interactive = true;
28 } else if( arg.equals("-v") ) { 28 } else if( arg.equals("-v") ) {
29 showVersion = true; 29 showVersion = true;
30 } else if( arg.equals("-e") ) { 30 } else if( arg.equals("-e") ) {
31 if( i == args.length ) 31 if( ++i == args.length )
32 error("'-e' needs argument"); 32 error("'-e' needs argument");
33 String cmd = args[i++]; 33 String cmd = args[i];
34 try { 34 try {
35 LuaFunction fn = BasicLib.load(lua,cmd); 35 LuaFunction fn = BasicLib.load(lua,cmd);
36 fn.call(lua); 36 fn.call(lua);
37 } catch(LuaException e) { 37 } catch(LuaException e) {
38 System.err.println("command line error: "+e.getMessage()); 38 System.err.println("command line error: "+e.getMessage());
49 } 49 }
50 System.exit(0); 50 System.exit(0);
51 } else { 51 } else {
52 error("unrecognized option '"+arg+"'"); 52 error("unrecognized option '"+arg+"'");
53 } 53 }
54 i++;
54 } 55 }
55 } 56 }
56 if( showVersion ) 57 if( showVersion )
57 System.out.println(version); 58 System.out.println(version);
58 if( i < args.length ) { 59 if( i < args.length ) {