-
Notifications
You must be signed in to change notification settings - Fork 1
/
prompts.js
60 lines (51 loc) · 1.43 KB
/
prompts.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const inquirer = require('inquirer')
const validators = require('./promptValidators')
const enterSequence = {
message: "Please input a sequence (seperate with commas ex: 1,1,2,3,5,8):",
type: "input",
name: "sequence",
validate: validators.sequenceValidator
}
const createSelectSequenceFromTop = (seqObj) => {
let promptObj = {
message: "These are the top matches. Select a sequence to learn more about it:",
type: "list",
name: "key"
}
let names = Object.keys(seqObj);
if (names.length > 5) {
names = names.slice(0, 4)
names.push('See more matches')
}
promptObj['choices'] = names;
return promptObj;
}
const createSelectSequenceFromAll = (seqObj) => {
let promptObj = {
message: "These are all of the matches. Select a sequence to learn more about it:",
type: "list",
name: "key"
}
promptObj['choices'] = Object.keys(seqObj)
promptObj['choices'].push(new inquirer.Separator())
return promptObj;
}
const sequenceMatchMenu = {
message: "What would you like to do next?",
type: "list",
name: "menuItem",
choices: ['Return to potential matches', 'Search a new sequence', 'Exit']
}
const noSequenceMatchMenu = {
message: "What would you like to do next?",
type: "list",
name: "menuItem",
choices: ['Search a new sequence', 'Exit']
}
module.exports = {
enterSequence,
createSelectSequenceFromTop,
createSelectSequenceFromAll,
sequenceMatchMenu,
noSequenceMatchMenu
}