Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

appendable-cli-menu

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appendable-cli-menu

Show a menu in the terminal were you can continuously append items

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

appendable-cli-menu

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.

Build status js-standard-style

Installation

npm install appendable-cli-menu

Usage

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 = require('bonjour')()
var menu = require('appendable-cli-menu')

var servers = menu('Select an HTTP server', function (server) {
  // stop looking when the user have selected an option
  browser.stop()
  console.log('You selected %s (host: %s)', server.name, server.value)
})

var browser = bonjour.find({ type: 'http' }, function (service) {
  servers.add({ name: service.name, value: service.host })
})

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.

License

MIT

Keywords

FAQs

Package last updated on 16 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc