A "simple as it get's" terminal based menu for numeric selection.
npm install simple-menu
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?
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
Add a line of text to the menu
- text - The text to show in the menu
menu.addText('Text');
Displays
Text
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
------------------------------------------------------------
Simple utility function to add a quit option that will execute a process.exit()
menu.addQuit();
Displays
1: Quit