Skip to content

Commit

Permalink
add the count command
Browse files Browse the repository at this point in the history
  • Loading branch information
GideonBature committed Oct 15, 2023
1 parent 931fe97 commit 05d38f5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions console.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,15 @@ def default(self, line):
args = line.split('.')

cls_name = args[0]
cls_method = args[1]
cls_cmd = args[1]

if cls_name in self.__classes:
if cls_method == "all()":
if cls_cmd == "all()":
self.do_all(cls_name)
elif cls_cmd == "count()":
_list = [v for k, v in storage.all().items()
if k.startswith(cls_name)]
print(len(_list))

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

0 comments on commit 05d38f5

Please sign in to comment.