-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTerminal.py
More file actions
65 lines (42 loc) · 1.55 KB
/
Terminal.py
File metadata and controls
65 lines (42 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Path: Source/Main/Terminal.py
from Source.DirectoryClass import Directory
import Source.Binaries as Binaries
from Source.User import User
rootdir = Directory("/")
user_input = ""
def bootProcess(rootdir: Directory):
# Boot the system
dirBootList = ["bin", "etc", "home", "lib", "mnt", "opt", "usr", "var"]
homebootList = ["documents", "downloads", "music", "pictures", "videos"]
binBootList = ["cd", "ls", "mkdir", "touch", "whoami"]
print("Booting the system...")
print("System booted successfully.")
__newuser = input("Enter your username: ")
Binaries.clear()
user = User(__newuser, rootdir)
# Create root directories and files
for i in dirBootList:
rootdir.addDirectory(i)
# Create bin files
for i in binBootList:
rootdir.subdirectories[0].addFile(i)
rootdir.subdirectories[2].addDirectory(__newuser)
homefile = rootdir.subdirectories[2].showDirectories()[0]
# Create home directories
for i in homebootList:
homefile.addDirectory(i)
print(f"Welcome to the terminal {__newuser}.")
print("Type 'help' to see the list of commands.")
return user
def getpath(user: User):
path = user.currentPath.name
parent = user.currentPath.parent
while parent is not None:
path = parent.name + "/" + path
parent = parent.parent
return path
# Initializing Terminal
user = bootProcess(rootdir)
while user_input != "exit":
user_input = input(f"{user.name}$ {getpath(user)} > ")
Binaries.switch(user_input, user)