1.0.1 • Published 10 years ago
simple-menu v1.0.1
simple-menu
A "simple as it get's" terminal based menu for numeric selection.
Installation
npm install simple-menuExample
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: LabeladdText(text)
Add a line of text to the menu
- text - The text to show in the menu
menu.addText('Text');Displays
TextaddBreak(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