Skip to content

Commit db1002a

Browse files
authored
Create pythonos_terminal.py
1 parent ba1de0e commit db1002a

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

clis/pythonos_terminal.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
class PythonOSTerminal:
2+
def __init__(self):
3+
self.files = [
4+
"documento.txt",
5+
"immagine.png",
6+
"appunti.md",
7+
"config.sys"
8+
]
9+
10+
def run_command(self, command: str) -> str:
11+
command = command.strip().lower()
12+
13+
if command == "help":
14+
return (
15+
"Comandi disponibili:\n"
16+
"help - mostra questo messaggio\n"
17+
"list - mostra i file\n"
18+
"clear - pulisce lo schermo\n"
19+
"exit - chiude il terminale"
20+
)
21+
22+
if command == "list":
23+
return "\n".join(self.files)
24+
25+
if command == "clear":
26+
return "[schermo pulito]"
27+
28+
if command == "exit":
29+
return "Chiudi la finestra del terminale o torna al desktop."
30+
31+
if not command:
32+
return ""
33+
34+
return f"Comando non riconosciuto: {command}"
35+
36+
def get_file_listing(self):
37+
return [f"- {name}" for name in self.files]
38+
39+
40+
# Avvio del terminale
41+
pythonosterminal = PythonOSTerminal()
42+
43+
while True:
44+
command = input("> ")
45+
result = pythonosterminal.run_command(command)
46+
47+
print(result)

0 commit comments

Comments
 (0)