summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/v2/DiceLangConsole.java
blob: c827edfc0f9262601ea76952c07a88cb3829413f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package bjc.dicelang.v2;

import java.util.Scanner;

public class DiceLangConsole {
	private int commandNumber;

	private DiceLangEngine eng;

	public DiceLangConsole(String[] args) {
		// @TODO do something with the args
		
		commandNumber = 0;

		eng = new DiceLangEngine();
	}

	public void run() {
		System.out.println("dice-lang v0.2");

		Scanner scn = new Scanner(System.in);

		System.out.printf("(%d) dice-lang> ", commandNumber);
		String comm = scn.nextLine();

		while(!comm.equals("quit") && !comm.equals("exit")) {
			System.out.printf("\tRaw command: %s\n", comm);

			boolean success = eng.runCommand(comm);

			if(success) 
				System.out.println("Command completed succesfully");
			else
				System.out.println("Command execution failed");

			commandNumber += 1;

			System.out.printf("(%d) dice-lang> ", commandNumber);
			comm = scn.nextLine();
		}

		scn.close();
	}

	public static void main(String[] args) {
		DiceLangConsole console = new DiceLangConsole(args);

		console.run();
	}
}