A Node.js module to show a menu in the terminal. Items in the menu can be added continuously and the user can choose any available item at any time.
npm install appendable-cli-menu
In this example we use the bonjour/zeroconf protocol to look for http servers on the local network. We add them to the menu as they are discovered and let the user choose one:
var bonjour =var menu =var servers =var browser = bonjour
The above call the
menu() will show en empty menu to the user:
? Select an HTTP server (waiting...)
The subsequent calls to the
servers.add() will add new options to the
menu as they become available:
? Select an HTTP server (use arrow keys) > mafintosh feross watson
The user can choose an item from the menu at any time. When he does, the
callback provided to
menu() will be called.