您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

33 行
1.2 KiB

4 年前
  1. 'use strict';
  2. module.exports = async(value, prompt, context = {}) => {
  3. let { choices, multiple } = prompt.options;
  4. let { size, submitted } = prompt.state;
  5. let prefix = context.prefix || await prompt.prefix();
  6. let separator = context.separator || await prompt.separator();
  7. let message = context.message || await prompt.message();
  8. // ? Select your favorite colors >
  9. // ^ ^ ^
  10. // prefix message separator
  11. let promptLine = [prefix, message, separator].filter(Boolean).join(' ');
  12. prompt.state.prompt = promptLine;
  13. let header = context.header || await prompt.header();
  14. let output = context.format || await prompt.format(value);
  15. let help = context.help || await prompt.error() || await prompt.hint();
  16. let body = context.body || await prompt.body();
  17. let footer = context.footer || await prompt.footer();
  18. if (output || !help) promptLine += ' ' + output;
  19. if (help && !promptLine.includes(help)) promptLine += ' ' + help;
  20. if (submitted && choices && multiple && !output && !body) {
  21. promptLine += prompt.styles.danger('No items were selected');
  22. }
  23. prompt.clear(size);
  24. prompt.write([header, promptLine, body, footer].filter(Boolean).join('\n'));
  25. prompt.restore();
  26. };