choice argument type

This commit is contained in:
Daniel Odendahl Jr
2018-03-17 13:02:45 +00:00
parent 7c12d04e42
commit 679bb538cb
17 changed files with 84 additions and 121 deletions
+2 -6
View File
@@ -24,12 +24,8 @@ module.exports = class MathQuizCommand extends Command {
{
key: 'difficulty',
prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`,
type: 'string',
validate: difficulty => {
if (difficulties.includes(difficulty.toLowerCase())) return true;
return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`;
},
parse: difficulty => difficulty.toLowerCase()
type: 'choice',
choices: difficulties
}
]
});
+4 -12
View File
@@ -22,24 +22,16 @@ module.exports = class QuizCommand extends Command {
{
key: 'type',
prompt: `Which type of question would you like to have? Either ${list(types, 'or')}.`,
type: 'string',
type: 'choice',
default: 'multiple',
validate: type => {
if (types.includes(type.toLowerCase())) return true;
return `Invalid type, please enter either ${list(types, 'or')}.`;
},
parse: type => type.toLowerCase()
choices: types
},
{
key: 'difficulty',
prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`,
type: 'string',
type: 'choice',
default: '',
validate: difficulty => {
if (difficulties.includes(difficulty.toLowerCase())) return true;
return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`;
},
parse: difficulty => difficulty.toLowerCase()
choices: difficulties
}
]
});
+2 -2
View File
@@ -13,8 +13,8 @@ module.exports = class RockPaperScissorsCommand extends Command {
{
key: 'choice',
prompt: 'Rock, Paper, or Scissors?',
type: 'string',
parse: choice => choice.toLowerCase()
type: 'choice',
choices
}
]
});
+2 -6
View File
@@ -24,12 +24,8 @@ module.exports = class TypingTestCommand extends Command {
{
key: 'difficulty',
prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`,
type: 'string',
validate: difficulty => {
if (difficulties.includes(difficulty.toLowerCase())) return true;
return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`;
},
parse: difficulty => difficulty.toLowerCase()
type: 'choice',
choices: difficulties
}
]
});