Add more functionality to mls

This commit is contained in:
Maxwell Jeffress 2024-07-04 17:20:49 +10:00
parent 9136168689
commit 926e65427c

16
main.py Normal file → Executable file
View File

@ -55,7 +55,17 @@ try:
matFile = open(argList[1]) matFile = open(argList[1])
print(matFile.read()) print(matFile.read())
elif argList[0] == "mls": elif argList[0] == "mls":
os.listdir(currentDirectory) try:
if argList[1] == "":
print(os.listdir(currentDirectory))
else:
argList[1] = mlsDirectory
if mlsDirectory[0] == "/":
print(os.listdir(mlsDirectory))
else:
print(os.listdir(currentDirectory + "/" + mlsDirectory))
except Exception:
print(os.listdir(currentDirectory))
elif argList[0] == "cd": elif argList[0] == "cd":
try: try:
directoryForCD = argList[1] directoryForCD = argList[1]
@ -72,7 +82,7 @@ try:
subprocess.run(argList) subprocess.run(argList)
except Exception: except Exception:
print("Command", command, "either doesn't exist, isn't in the path or isn't in this directory.") print("Command", command, "either doesn't exist, isn't in the path or isn't in this directory.")
except Exception: #except Exception:
print("Looks like there was an error. Exiting...") # print("Looks like there was an error. Exiting...")
except KeyboardInterrupt: except KeyboardInterrupt:
print(" detected! Exiting...") print(" detected! Exiting...")