Skip to content

Commit

Permalink
add the show command
Browse files Browse the repository at this point in the history
  • Loading branch information
GideonBature committed Oct 15, 2023
1 parent 22ad2b4 commit e52f7db
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion console.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def default(self, line):
Updates an instance based on its ID
Updates an instance based on it's ID with a dict
Usage:
Usage:
<class name>.all()
<class name>.count()
<class name>.show(<id>)
Expand All @@ -245,6 +245,13 @@ def default(self, line):
<class name>: The class name
all(): count command
count(): count command
<id>: the id
show(): show command
destroy(): destroy command
update(): update command
<attribute name>: attribute name
<attribute value>: attribute value
<dictionary representation>: dict representation
Returns:
None
"""
Expand All @@ -260,6 +267,9 @@ def default(self, line):
_list = [v for k, v in storage.all().items()
if k.startswith(cls_name)]
print(len(_list))
elif cls_cmd.startswith("show"):
_id = cls_cmd.split('"')[1]
self.do_show(f"{cls_name} {_id}")

def postcmd(self, stop, line):
"""Program exit cleanly in response to the quit command
Expand Down

0 comments on commit e52f7db

Please sign in to comment.