aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts/cardbase/standalone
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/equalparts/cardbase/standalone')
-rw-r--r--src/eu/equalparts/cardbase/standalone/CardBaseCLI.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/eu/equalparts/cardbase/standalone/CardBaseCLI.java b/src/eu/equalparts/cardbase/standalone/CardBaseCLI.java
new file mode 100644
index 0000000..4b746b2
--- /dev/null
+++ b/src/eu/equalparts/cardbase/standalone/CardBaseCLI.java
@@ -0,0 +1,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();
+ }
+
+
+ }
+
+}