Fully implement cat

This commit is contained in:
Maxwell 2024-07-03 12:38:20 +10:00
parent e57abc18a9
commit da523b9644
2 changed files with 32 additions and 2 deletions

14
main.py
View File

@ -1,16 +1,26 @@
import os
import subprocess
import re
initDirectory = os.path.dirname(os.path.realpath(__file__))
currentDirectory = initDirectory
version = "0.0.1"
def grabArgument(fullCommand, commandRan):
fullCommand.replace(commandRan, "")
while True:
command = input(currentDirectory + " > ")
if command == "pwd":
print(currentDirectory)
elif command == "cat *":
print("You ran cat")
elif command == ("cat"):
try:
catFile = input("File to catalog: ")
catFileOpened = open(catFile)
print(catFileOpened.read())
except Exception:
print("File", catFile, "either doesn't exist or isn't in this directory.")
elif command == "version":
print(version)
else:

20
main.py! Normal file
View File

@ -0,0 +1,20 @@
import os
import subprocess
initDirectory = os.path.dirname(os.path.realpath(__file__))
currentDirectory = initDirectory
version = "0.0.1"
def grabArgument(fullCommand, commandRan):
fullCommand.replace(commandRan, "")
while True:
command = input(currentDirectory + " > ")
if command == "pwd":
print(currentDirectory)
elif command == ("cat", *):
grabArgument(command, cat )
elif command == "version":
print(version)
else:
subprocess.run(command)