changeset 3276:81c8910db91f

jp (event): new `list` command to get evens available in a service
author Goffi <goffi@goffi.org>
date Mon, 18 May 2020 23:48:40 +0200
parents 55eeb0dfd313
children cf07641b764d
files doc/jp/event.rst sat_frontends/jp/cmd_event.py
diffstat 2 files changed, 43 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/doc/jp/event.rst	Mon May 18 23:43:06 2020 +0200
+++ b/doc/jp/event.rst	Mon May 18 23:48:40 2020 +0200
@@ -5,6 +5,18 @@
 Event commands allows you to create/modify or get data about an event, and to manage your
 invitees.
 
+list
+====
+
+List events available on a service
+
+example
+-------
+
+Retrieve events of profile::
+
+  $ jp event list
+
 .. _jp-event_get:
 
 get
--- a/sat_frontends/jp/cmd_event.py	Mon May 18 23:43:06 2020 +0200
+++ b/sat_frontends/jp/cmd_event.py	Mon May 18 23:48:40 2020 +0200
@@ -35,6 +35,36 @@
 # TODO: move date parsing to base, it may be useful for other commands
 
 
+class List(base.CommandBase):
+    def __init__(self, host):
+        base.CommandBase.__init__(
+            self,
+            host,
+            "list",
+            use_output=C.OUTPUT_LIST_DICT,
+            use_pubsub=True,
+            use_verbose=True,
+            help=_("get list of registered events"),
+        )
+
+    def add_parser_options(self):
+        pass
+
+    async def start(self):
+        try:
+            events = await self.host.bridge.eventsList(
+                self.args.service,
+                self.args.node,
+                self.profile,
+            )
+        except Exception as e:
+            self.disp(f"can't get list of events: {e}", error=True)
+            self.host.quit(C.EXIT_BRIDGE_ERRBACK)
+        else:
+            await self.output(events)
+            self.host.quit()
+
+
 class Get(base.CommandBase):
     def __init__(self, host):
         base.CommandBase.__init__(
@@ -544,7 +574,7 @@
 
 
 class Event(base.CommandBase):
-    subcommands = (Get, Create, Modify, Invitee)
+    subcommands = (List, Get, Create, Modify, Invitee)
 
     def __init__(self, host):
         super(Event, self).__init__(