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
+4 -12
View File
@@ -16,22 +16,14 @@ module.exports = class CurrencyCommand extends Command {
{
key: 'base',
prompt: `What currency code do you want to use as the base? Either ${list(codes, 'or')}.`,
type: 'string',
validate: base => {
if (codes.includes(base.toUpperCase())) return true;
return `Invalid base, please enter either ${list(codes, 'or')}.`;
},
parse: base => base.toUpperCase()
type: 'choice',
choices: codes
},
{
key: 'target',
prompt: `What currency code do you want to convert to? Either ${list(codes, 'or')}.`,
type: 'string',
validate: target => {
if (codes.includes(target.toUpperCase())) return true;
return `Invalid target, please enter either ${list(codes, 'or')}.`;
},
parse: target => target.toUpperCase()
type: 'choice',
choices: codes
},
{
key: 'amount',