corda / com.r3.corda.networkmanage.common / Menu

Menu

class Menu

A generic menu class for console based interactions with user. Inspired by https://github.com/bryandh/genericmenu, but adjusted to our the particular needs of this project.

Constructors

<init>

Menu(renderer: Renderer)

A generic menu class for console based interactions with user. Inspired by https://github.com/bryandh/genericmenu, but adjusted to our the particular needs of this project.

Functions

addItem

fun addItem(key: String, label: String, action: () -> Unit, isTerminating: Boolean = false): Menu

Adds a menu item to the list of the menu items. The order in which the items are added matters. If the exit option is set (@see setExitOption then it will be displayed always as the last element in the menu.

setExitOption

fun setExitOption(key: String, label: String): Menu

Sets the exit option with given key and label.

showMenu

fun showMenu(): Unit

Shows the menu built out of the given menu items and (if present) exit option.

withExceptionHandler

fun withExceptionHandler(handler: (exception: Exception) -> Unit): Menu

Assigns the exception handler for this menu. The exception handler is invoked every time any of the menu item selection handler function throws an exception.