jp (event): new list command to get evens available in a service

This commit is contained in:
Goffi 2020-05-18 23:48:40 +02:00
commit 85a3e6edfb
2 changed files with 43 additions and 1 deletions

View file

@ -5,6 +5,18 @@ event: events management
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

View file

@ -35,6 +35,36 @@ OUTPUT_OPT_TABLE = "table"
# 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 Invitee(base.CommandBase):
class Event(base.CommandBase):
subcommands = (Get, Create, Modify, Invitee)
subcommands = (List, Get, Create, Modify, Invitee)
def __init__(self, host):
super(Event, self).__init__(