Return no selection if the user aborted selection
Also expose success state
This commit is contained in:
parent
ad3fd751cc
commit
0517b4d996
|
@ -105,13 +105,20 @@ class CliMenu:
|
||||||
self._items.append(CliMenuOption(text, self._item_num, item=item))
|
self._items.append(CliMenuOption(text, self._item_num, item=item))
|
||||||
self._item_num += 1
|
self._item_num += 1
|
||||||
|
|
||||||
def get_selection(self):
|
@property
|
||||||
|
def success(self):
|
||||||
if not self._ran:
|
if not self._ran:
|
||||||
self._run()
|
self._run()
|
||||||
|
|
||||||
|
return self._success
|
||||||
|
|
||||||
|
def get_selection(self):
|
||||||
|
if self.success:
|
||||||
item = self._items[self._pos]
|
item = self._items[self._pos]
|
||||||
|
|
||||||
return (item.num, item.item)
|
return (item.num, item.item)
|
||||||
|
else:
|
||||||
|
return (None, None)
|
||||||
|
|
||||||
def get_selection_num(self):
|
def get_selection_num(self):
|
||||||
return self.get_selection()[0]
|
return self.get_selection()[0]
|
||||||
|
|
Loading…
Reference in New Issue