Add better config file support
This commit is contained in:
		
							
								
								
									
										10
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								main.py
									
									
									
									
									
								
							@@ -20,10 +20,11 @@ argList = ["", ""]
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
# Start work on checking whether a config file exists
 | 
					# Start work on checking whether a config file exists
 | 
				
			||||||
if os.path.isfile(expanduser("~") + "/.config/mash/mash.conf") == False:
 | 
					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
 | 
					# Parse config file, adding variables
 | 
				
			||||||
configFileFile = open((expanduser("~") + "/.config/mash/mash.conf"))
 | 
					configFileFile = open(configFilePath)
 | 
				
			||||||
configFile = configFileFile.read()
 | 
					configFile = configFileFile.read()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
confArgNumber = 0
 | 
					confArgNumber = 0
 | 
				
			||||||
@@ -80,7 +81,8 @@ def mainLoop(startDir):
 | 
				
			|||||||
            # Set directory and prompt for input.
 | 
					            # Set directory and prompt for input.
 | 
				
			||||||
            os.chdir(currentDirectory)
 | 
					            os.chdir(currentDirectory)
 | 
				
			||||||
            command = input(Fore.GREEN + user + Fore.WHITE + "@" + socket.gethostname() + Fore.BLUE + " " + currentDirectory + Fore.WHITE + " > ")
 | 
					            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.
 | 
					            # Clean some things up for the argument parser.
 | 
				
			||||||
            argNumber = 0
 | 
					            argNumber = 0
 | 
				
			||||||
            argList.clear()
 | 
					            argList.clear()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user