simple-menu

1.0.1 • Public • Published

simple-menu

A "simple as it get's" terminal based menu for numeric selection.

Installation

npm install simple-menu

Example

var menu = require('simple-menu');

menu.reset();

menu.addText('Main Menu');
menu.addBreak('-', 60);

menu.addOption('Print \'Hello World\'', function() {
  console.log('Hello World');
});

menu.addBreak('-', 60);
menu.addQuit();

menu.init('What would you like to do?');

Displays

Main Menu
------------------------------------------------------------
1: Print 'Hello World'
------------------------------------------------------------
2: Quit

What would you like to do?

Methods

addOption(label, callback)

Add a selectable option to the menu

  • label - The label to show for this selectable item
  • callback - The function to execute when this item has been selected
menu.addOption('Label', callback);

Displays

1: Label

addText(text)

Add a line of text to the menu

  • text - The text to show in the menu
menu.addText('Text');

Displays

Text

addBreak(character, count)

Add a line break to the menu

  • character - The character that will make up the line break
  • count - How many times to repeat the character
menu.addBreak('-', 60);

Displays

------------------------------------------------------------

addQuit()

Simple utility function to add a quit option that will execute a process.exit()

menu.addQuit();

Displays

1: Quit

Readme

Keywords

Package Sidebar

Install

npm i simple-menu

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • mattaschmann