@@ -231,6 +231,9 @@ class HamsterView(abc.ABC):
231231 def current (self , action ):
232232 pass
233233
234+ def activities (self , facts ):
235+ pass
236+
234237class HamsterViewText (HamsterView ):
235238
236239 def current (self , action ):
@@ -240,6 +243,10 @@ def current(self, action):
240243 else :
241244 print ((_ ("No activity" )))
242245
246+ def activities (self , facts ):
247+ for activity in facts :
248+ print ("{}@{}" .format (activity ['name' ], activity ['category' ]))
249+
243250class HamsterViewJSON (HamsterView ):
244251
245252 def _dump_fact (self , fact ):
@@ -259,6 +266,10 @@ def current(self, action):
259266 output = self ._dump_fact (action )
260267 print (json .dumps (output ))
261268
269+ def activities (self , facts ):
270+ output = [{"name" :activity ['name' ], "category" :activity ['category' ]}
271+ for activity in facts ]
272+ print (json .dumps (output ))
262273class HamsterCli (object ):
263274 """Command line interface."""
264275
@@ -335,8 +346,7 @@ def _activities(self, search=""):
335346 def activities (self , * args ):
336347 '''Print the names of all the activities.'''
337348 search = args [0 ] if args else ""
338- for activity in self .storage .get_activities (search ):
339- print ("{}@{}" .format (activity ['name' ], activity ['category' ]))
349+ self .view .activities (self .storage .get_activities (search ))
340350
341351 def categories (self , * args ):
342352 '''Print the names of all the categories.'''
0 commit comments