mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 22:32:52 +02:00
More intuitive story picker
This commit is contained in:
+18
-3
@@ -26,10 +26,25 @@ module.exports = class KinoCommand extends Command {
|
|||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'story',
|
key: 'story',
|
||||||
prompt: `What story do you want to read? Either ${list(stories, 'or')}.`,
|
prompt: stripIndents`
|
||||||
|
What story do you want to read? You can type the number or the name.
|
||||||
|
\`\`\`
|
||||||
|
${stories.map((story, i) => `${i.toString().padStart(2, '0')}. ${story}`).join('\n')}
|
||||||
|
\`\`\`
|
||||||
|
`,
|
||||||
type: 'string',
|
type: 'string',
|
||||||
oneOf: stories.map(story => story.toLowerCase()),
|
validate: story => {
|
||||||
parse: story => story.toLowerCase()
|
if (stories.some(story => story.toLowerCase() === story.toLowerCase())) return true;
|
||||||
|
const num = Number.parseInt(story, 10);
|
||||||
|
return Boolean(stories[num]);
|
||||||
|
},
|
||||||
|
parse: story => {
|
||||||
|
if (stories.some(story => story.toLowerCase() === story.toLowerCase())) {
|
||||||
|
return story.toLowerCase();
|
||||||
|
}
|
||||||
|
const num = Number.parseInt(story, 10);
|
||||||
|
return stories[num];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user