-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathos.py
More file actions
118 lines (99 loc) · 3.79 KB
/
os.py
File metadata and controls
118 lines (99 loc) · 3.79 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import random
import os
import pyfiglet
import time
# Github: https://github.com/OLaachkar
def view_all_cmds():
windows_logo = pyfiglet.figlet_format("FULL COMMANDS LIST")
print("|----------------------------------------------------------------------------|")
print("| 1: Create File | | 2. Create Folder | | 3. Edit Folder |")
print("| 3: Delete File | | 4. Delete Folder | | 5. Edit File |")
print("| 5: Exit | | 6. View all Cmds | | 7. Return Menu |")
print("|----------------------------------------------------------------------------|")
choice = input("Enter your choice: ")
if choice == "1" or choice == "Create File":
create_file()
elif choice == "2" or choice == "Create Folder":
create_folder()
elif choice == "3" or choice == "Edit Folder":
edit_folder()
elif choice == "4" or choice == "Delete Folder":
delete_folder()
elif choice == "5" or choice == "Edit File":
edit_file()
elif choice == "6" or choice == "Exit":
view_all_cmds()
elif choice == "7" or choice == "Return Menu":
menu()
else:
print("Invalid choice")
view_all_cmds()
def edit_folder():
folder_name = input("Enter the name of the folder: ")
os.rename(f"windows/{folder_name}", f"windows/{input('Enter the new name of the folder: ')}")
print(f"Folder {folder_name} edited successfully")
menu()
def edit_file():
file_name = input("Enter the name of the file: ")
file_content = input("Enter the content of the file: ")
with open(f"windows/{file_name}", "w") as file:
file.write(file_content)
print(f"File {file_name} edited successfully")
menu()
def create_file():
file_name = input("Enter the name of the file: ")
file_content = input("Enter the content of the file: ")
with open(f"windows/{file_name}", "w") as file:
file.write(file_content)
print(f"File {file_name} created successfully")
menu()
def delete_file():
file_name = input("Enter the name of the file: ")
os.remove(f"windows/{file_name}")
print(f"File {file_name} deleted successfully")
menu()
def create_folder():
folder_name = input("Enter the name of the folder: ")
os.makedirs(f"windows/{folder_name}", exist_ok=True)
print(f"Folder {folder_name} created successfully")
menu()
def delete_folder():
folder_name = input("Enter the name of the folder: ")
os.rmdir(f"windows/{folder_name}")
print(f"Folder {folder_name} deleted successfully")
menu()
def exit():
print("Exiting...")
exit()
def menu():
windows_logo = pyfiglet.figlet_format("WINDOWS CLI")
print(windows_logo)
os.makedirs("windows", exist_ok=True)
print("|------------------------------------------------|")
print("| 1: Create File | | 2. Create Folder |")
print("| 3: Delete File | | 4. Delete Folder |")
print("| 5: Exit | | 6. View all Cmds |")
print("|------------------------------------------------|")
choice = input("Enter your choice: ")
if choice == "1" or choice == "Create File":
create_file()
elif choice == "2" or choice == "Create Folder":
create_folder()
elif choice == "3" or choice == "Delete File":
delete_file()
elif choice == "4" or choice == "Delete Folder":
delete_folder()
elif choice == "5" or choice == "Exit":
exit()
elif choice == "6" or choice == "View all Cmds":
view_all_cmds()
else:
print("Invalid choice")
menu()
if __name__ == "__main__":
print("Starting windows cli", end="", flush=True)
for i in range(3):
print(".", end="", flush=True)
time.sleep(0.5)
print()
menu()