File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments