From c416f8fb5ca2e043bbd0a26df6bcb37b5fa966b3 Mon Sep 17 00:00:00 2001
From: lstrsrmn <alistair.sirman@gmail.com>
Date: Wed, 20 Oct 2021 23:52:28 +0100
Subject: [PATCH] Now uses command Line input

---
 src/Interpreter.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/Interpreter.java b/src/Interpreter.java
index 991be3b..8391934 100644
--- a/src/Interpreter.java
+++ b/src/Interpreter.java
@@ -7,9 +7,16 @@ import java.util.*;
  */
 public class Interpreter {
     public static void main(String[] args) {
+        // spaces define new arguments, and as the program only takes 1, the file name, we can safely concatenate them
+        // into 1 string, adding spaces where the command line has split it
+        StringBuilder fileString = new StringBuilder();
+        for (String s : args) {
+            fileString.append(s);
+            fileString.append(" ");
+        }
         try {
             // reading the file
-            File filePath = new File("C:\\Users\\alist\\IdeaProjects\\Space Cowboys\\src\\program.bb");
+            File filePath = new File(fileString.toString());
             Scanner reader = new Scanner(filePath);
             StringBuilder data = new StringBuilder();
             // moves the file into a string
@@ -33,7 +40,8 @@ public class Interpreter {
         }
         catch (FileNotFoundException e){
             System.out.println("File can't be found.");
-            e.printStackTrace();
+             e.printStackTrace();
+            // System.exit(1);
         }
     }
 }
-- 
GitLab