mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-20 14:00:22 +02:00
choice argument type
This commit is contained in:
@@ -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
@@ -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
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user