-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconsole.py
52 lines (43 loc) · 1.07 KB
/
console.py
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
#!/usr/bin/python3
"""
The Command line interface of the entire application
"""
import cmd
from models.base_model import BaseModel
from models import storage
class HBNBCommand(cmd.Cmd):
"""
The command line interface of the application
"""
prompt = "(hbnb) "
def do_EOF(self, arg):
"""
End Of File
"""
return True
def do_quit(self, arg):
"""
quit command to exit the program
"""
return True
def emptyline(self) -> bool:
""" Do nothing upon a new lie """
pass
def do_create(self, arg):
""" creates new instance of a BaseModel, and save it into
a JSON file
"""
try:
obj = eval(arg)()
obj.save()
except SyntaxError:
print("** class missing **")
except NameError:
print("** class doesn't exist **")
else:
print(obj.id)
def do_show(self, *arg):
"""Show Class instance and it id"""
pass
if __name__ == "__main__":
HBNBCommand().cmdloop()