diff --git a/src/hamster-cli.py b/src/hamster-cli.py old mode 100644 new mode 100755 index 1cfc5e771..4bcbf40d2 --- a/src/hamster-cli.py +++ b/src/hamster-cli.py @@ -234,6 +234,9 @@ def current(self, action): def activities(self, facts): pass + def categories(self, facts): + pass + class HamsterViewText(HamsterView): def current(self, action): @@ -247,6 +250,10 @@ def activities(self, facts): for activity in facts: print("{}@{}".format(activity['name'], activity['category'])) + def categories(self, categories): + for category in categories: + print(category['name']) + class HamsterViewJSON(HamsterView): def _dump_fact(self, fact): @@ -270,6 +277,11 @@ def activities(self, facts): output = [ {"name":activity['name'], "category":activity['category']} for activity in facts] print(json.dumps(output)) + + def categories(self, categories): + output = [ category['name'] for category in categories ] + print(json.dumps(output)) + class HamsterCli(object): """Command line interface.""" @@ -350,8 +362,7 @@ def activities(self, *args): def categories(self, *args): '''Print the names of all the categories.''' - for category in self.storage.get_categories(): - print(category['name']) + self.view.categories(self.storage.get_categories()) def list(self, *times):