From 3072753159f683e4e2188fd2505068b2a9e911fa Mon Sep 17 00:00:00 2001
From: max <maxwelljeffress@proton.me>
Date: Wed, 10 Jul 2024 19:04:37 +1000
Subject: [PATCH] Add start of config parser

---
 main.py | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/main.py b/main.py
index 2451ee1..d8d8fa3 100755
--- a/main.py
+++ b/main.py
@@ -20,12 +20,28 @@ currentDirectory = initDirectory
 argList = ["", ""]
 
 # Start work on checking whether a config file exists
-if os.path.isfile(expanduser("~") + "/.config/mash/mash.conf") == True:
-    configFile = open(expanduser("~") + "/.config/mash/mash.conf")
-else:
+if os.path.isfile(expanduser("~") + "/.config/mash/mash.conf") == False:
     print("Config file does not exist. Copying default file to ~/.config/mash/mash.conf")
     shutil.copyfile("/etc/mash/mash.conf", (expanduser("~") + "/.config/mash/mash.conf"))
 
+# Parse config file, adding variables
+configFileFile = open((expanduser("~") + "/.config/mash/mash.conf"))
+configFile = configFileFile.read()
+
+confArgNumber = 0
+confArgList = ["", ""]
+
+for line in configFile:
+    for letter in line:
+        if letter == ' ':
+            confArgNumber = confArgNumber + 1
+        else: 
+            try:
+                confArgList[confArgNumber] = confArgList[confArgNumber] + letter
+            except Exception:
+                confArgList.append(letter)
+print(confArgList)
+
 # Write the time to the history file
 historyFile = open((expanduser("~") + "/.history.mash"), "a")
 historyFile.write("\n")
@@ -60,6 +76,10 @@ try:
         for word in argList:
             if word == "&&":
                 print("This hasnt been implemented yet hahahahah")
+            elif word == "&":
+                print("This hasnt been implemented yet heheheheh")
+            elif word == "|":
+                print("What are you? A pipe master? We dont like those people here")
         
         # Built in commands section
         if argList[0] == "help":
@@ -109,7 +129,8 @@ try:
             print(historyReadFile.read())
         elif argList[0] == "mtime":
             print(datetime.now())
-        
+        elif argList[0] == "printconf":
+            print(configFile)
         # If a built in command isn't what you wanted, run a new subprocess.
         else:
             try: