Fix a couple little bugs with a temporary fix to be worked on later
This commit is contained in:
parent
2b9763cf2c
commit
4f130ce28c
29
main.py
29
main.py
|
@ -1,20 +1,19 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import os
|
import os
|
||||||
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
import re
|
from colorama import Fore
|
||||||
|
|
||||||
initDirectory = os.path.dirname(os.path.realpath(__file__))
|
initDirectory = os.path.dirname(os.path.realpath(__file__))
|
||||||
currentDirectory = initDirectory
|
currentDirectory = initDirectory
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
user = os.getlogin()
|
user = os.getlogin()
|
||||||
|
|
||||||
print("Welcome to Mash, " + user + "! Mash is currently on version " + version)
|
print("Welcome to Mash, " + user + "@" + socket.gethostname() + "! Mash is currently on version " + version)
|
||||||
|
|
||||||
def grabArgument(fullCommand, commandRan):
|
|
||||||
fullCommand.replace(commandRan, "")
|
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
command = input(currentDirectory + " > ")
|
command = input(Fore.GREEN + user + Fore.WHITE + "@" + socket.gethostname() + Fore.BLUE + " " + currentDirectory + Fore.WHITE + " > ")
|
||||||
if command == "help":
|
if command == "help":
|
||||||
print("This is Mash, Max's Shell. Mash has a few built in commands, which you can use to run commands, view files and interact with your system.")
|
print("This is Mash, Max's Shell. Mash has a few built in commands, which you can use to run commands, view files and interact with your system.")
|
||||||
print("Some commands you can run:")
|
print("Some commands you can run:")
|
||||||
|
@ -41,6 +40,11 @@ try:
|
||||||
print("That directory doesn't exist.")
|
print("That directory doesn't exist.")
|
||||||
else:
|
else:
|
||||||
currentDirectory = cdDirectory
|
currentDirectory = cdDirectory
|
||||||
|
elif cdDirectory == ".":
|
||||||
|
currentDirectory == currentDirectory
|
||||||
|
elif cdDirectory == "..":
|
||||||
|
currentDirectory == currentDirectory
|
||||||
|
print("I'm working on that lol")
|
||||||
else:
|
else:
|
||||||
if os.path.isdir(currentDirectory + cdDirectory) == False:
|
if os.path.isdir(currentDirectory + cdDirectory) == False:
|
||||||
if os.path.isfile(currentDirectory + cdDirectory) == True:
|
if os.path.isfile(currentDirectory + cdDirectory) == True:
|
||||||
|
@ -54,15 +58,24 @@ try:
|
||||||
elif command == ("cat"):
|
elif command == ("cat"):
|
||||||
try:
|
try:
|
||||||
catFile = input("File to catalog: ")
|
catFile = input("File to catalog: ")
|
||||||
catFileOpened = open(catFile)
|
if catFile[0] == "/":
|
||||||
print(catFileOpened.read())
|
catFileOpened = open(catFile)
|
||||||
|
print(catFileOpened.read)
|
||||||
|
else:
|
||||||
|
catFileOpened = open(currentDirectory + catFile)
|
||||||
|
print(catFileOpened.read())
|
||||||
except Exception:
|
except Exception:
|
||||||
print("File", catFile, "either doesn't exist or isn't in this directory.")
|
print("File", catFile, "either doesn't exist or isn't in this directory.")
|
||||||
|
elif command == "touch":
|
||||||
|
touchName = input("File name?")
|
||||||
|
|
||||||
|
elif command == "ls":
|
||||||
|
print(os.listdir())
|
||||||
elif command == "version":
|
elif command == "version":
|
||||||
print(version)
|
print(version)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
subprocess.run(command)
|
subprocess.run(command, shell=True)
|
||||||
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:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user