aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/equalparts/cardbase/standalone
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2015-06-03 20:36:07 +0200
committerEduardo Pedroni <e.pedroni91@gmail.com>2015-06-03 20:36:07 +0200
commit98a75846c69f53f17389401096d2a19c697045d3 (patch)
tree8b9512c9dc66abfa0accec59761f25ed487728d6 /src/eu/equalparts/cardbase/standalone
parentc072ed0ac345a7e421cb0612048d4cd534bf6e73 (diff)
Have a working example to parse JSON sets and get cards by number
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();
+ }
+
+
+ }
+
+}