Add start of config parser
This commit is contained in:
parent
d87b1ff110
commit
3072753159
29
main.py
29
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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user