From ac03e87e028b48909c3ccf2ff727ba0d908c1ba0 Mon Sep 17 00:00:00 2001 From: Maxwell Date: Mon, 15 Jul 2024 14:05:01 +1000 Subject: [PATCH] Add better config file support --- main.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 7140202..f3243ae 100755 --- a/main.py +++ b/main.py @@ -20,10 +20,11 @@ argList = ["", ""] # Start work on checking whether a config file exists if os.path.isfile(expanduser("~") + "/.config/mash/mash.conf") == False: - print("Config file does not exist. Make a file at .config/mash/mash.conf to configure things") - + configFilePath = "/etc/mash/mash.conf" +else: + configFilePath = (expanduser("~") + "/.config/mash/mash.conf") # Parse config file, adding variables -configFileFile = open((expanduser("~") + "/.config/mash/mash.conf")) +configFileFile = open(configFilePath) configFile = configFileFile.read() confArgNumber = 0 @@ -80,7 +81,8 @@ def mainLoop(startDir): # Set directory and prompt for input. os.chdir(currentDirectory) command = input(Fore.GREEN + user + Fore.WHITE + "@" + socket.gethostname() + Fore.BLUE + " " + currentDirectory + Fore.WHITE + " > ") - + if command == "" : + mainLoop(currentDirectory) # Clean some things up for the argument parser. argNumber = 0 argList.clear()