aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts/cardbase/standalone/CardBaseCLI.java
blob: 4b746b283e929822f0deaf39019b0b01b8e708ee (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package eu.equalparts.cardbase.standalone;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

import eu.equalparts.cardbase.data.CardBase;

/**
 * This provides a lightweight CLI for interacting with cardbase files. 
 * 
 */
public class CardBaseCLI {
	
	/**
	 * Execute the interface.
	 * 
	 * @param args the first argument is the cardbase file. Further arguments are ignored.
	 */
	public static void main(String... args) {

		System.out.println("Welcome to cardbase");
		CardBase cb;

		// construct the cardbase
		if (args.length > 0) {
			System.out.println("Building cardbase from " + args[0]);
			cb = new CardBase(new File(args[0]));
		} else {
			System.out.println("No cardbase file was provided, initialising a clean cardbase");
			cb = new CardBase();
		}
		
		// main UI loop
		try {
			// initialise necessary components
			System.out.println("Fetching card sets from upstream");
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			boolean exit = false;
			
			while (!exit) {
				String rawInput = br.readLine().trim().toLowerCase();
				String[] commands = rawInput.split("[ \t]+");
				
				if (commands.length > 0) {
					switch (commands[0]) {
					case "exit":
						exit = true;
						break;
					case "sets":
						break;
					case "set":
						break;
					case "write":
						break;
					default:
						break;
					}
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	
	}
	
}