jp (pubsub/delete): delete command implementation (to delete an item)
This commit is contained in:
parent
364130bcbe
commit
2795935703
1 changed files with 37 additions and 1 deletions
|
|
@ -299,6 +299,42 @@ class Get(base.CommandBase):
|
|||
callback=self.psItemsGetCb,
|
||||
errback=self.psItemsGetEb)
|
||||
|
||||
class Delete(base.CommandBase):
|
||||
|
||||
def __init__(self, host):
|
||||
base.CommandBase.__init__(self, host, 'delete', use_pubsub_node_req=True, help=_(u'delete an item'))
|
||||
self.need_loop=True
|
||||
|
||||
def add_parser_options(self):
|
||||
self.parser.add_argument("item", nargs='?', type=base.unicode_decoder, help=_(u"item to delete"))
|
||||
self.parser.add_argument("-f", "--force", action='store_true', help=_(u"delete without confirmation"))
|
||||
self.parser.add_argument("-n", "--notify", action='store_true', help=_(u"notify deletion"))
|
||||
|
||||
def psItemsDeleteCb(self):
|
||||
self.disp(_(u'item {item_id} has been deleted').format(item_id=self.args.item))
|
||||
self.host.quit(C.EXIT_OK)
|
||||
|
||||
def start(self):
|
||||
common.checkURI(self.args)
|
||||
if not self.args.item:
|
||||
self.parser.error(_(u"You need to specify an item to delete"))
|
||||
if not self.args.force:
|
||||
message = _(u"Are you sure to delete item {item_id} ?").format(item_id=self.args.item)
|
||||
res = raw_input("{} (y/N)? ".format(message))
|
||||
if res not in ("y", "Y"):
|
||||
self.disp(_(u"Item deletion cancelled"))
|
||||
self.host.quit(2)
|
||||
self.host.bridge.psRetractItem(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.args.item,
|
||||
self.args.notify,
|
||||
self.profile,
|
||||
callback=self.psItemsDeleteCb,
|
||||
errback=partial(self.errback,
|
||||
msg=_(u"can't delete item: {}"),
|
||||
exit_code=C.EXIT_BRIDGE_ERRBACK))
|
||||
|
||||
|
||||
class Edit(base.CommandBase, common.BaseEdit):
|
||||
|
||||
|
|
@ -411,7 +447,7 @@ class Uri(base.CommandBase):
|
|||
|
||||
|
||||
class Pubsub(base.CommandBase):
|
||||
subcommands = (Get, Edit, Node, Affiliations, Uri)
|
||||
subcommands = (Get, Delete, Edit, Node, Affiliations, Uri)
|
||||
|
||||
def __init__(self, host):
|
||||
super(Pubsub, self).__init__(host, 'pubsub', use_profile=False, help=_('PubSub nodes/items management'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue