-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.js
38 lines (36 loc) · 1 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// A simple interactive test for the console-menu module.
const menu = require('./console-menu');
menu([
{ hotkey: '1', title: 'One' },
{ hotkey: '2', title: 'Two', selected: true },
{ hotkey: '3', title: 'Three' },
{ hotkey: '4', title: 'Four' },
{ separator: true },
{ hotkey: '0', title: 'Do something else...', cascade: true },
{ separator: true },
{ hotkey: '?', title: 'Help' },
], {
header: 'Test menu',
border: true,
}).then(item => {
if(item && item.cascade) {
return menu(['a','b','c','d','e','f','g','h','i','j'].map(hotkey => {
return {
hotkey,
title: 'Item ' + hotkey.toUpperCase(),
};
}), {
header: 'Another menu',
border: true,
pageSize: 5,
});
} else {
return item;
}
}).then(item => {
if (item) {
console.log('You chose: ' + JSON.stringify(item));
} else {
console.log('You cancelled the menu.');
}
});