(options: BuildEpilogOptions)
| 20 | formattedNotes?: string |
| 21 | } |
| 22 | export const buildEpilog = (options: BuildEpilogOptions): string => { |
| 23 | const commandName = options.command.split(' ')[0] |
| 24 | const { topics, subCommands } = findTopicsAndSubcommands(commandName) |
| 25 | |
| 26 | const parts: string[] = [] |
| 27 | if (options.notes || options.formattedNotes) { |
| 28 | const notesArray = (typeof options.notes === 'string' ? [options.notes] : [...(options.notes ?? [])]) |
| 29 | .map(note => ` ${note}`) |
| 30 | if (options.formattedNotes) { |
| 31 | notesArray.push(options.formattedNotes) |
| 32 | } |
| 33 | parts.push('Notes:\n' + notesArray.join('\n')) |
| 34 | } |
| 35 | if (options.apiDocs) { |
| 36 | parts.push(apiDocsURL(options.apiDocs)) |
| 37 | } |
| 38 | if (topics.length) { |
| 39 | parts.push('Topics:\n' + topics.map(topic => ` ${topic}`).join('\n')) |
| 40 | } |
| 41 | if (subCommands.length) { |
| 42 | const data = subCommands.map(subCommand => [` ${subCommand.relatedName}`, subCommand.command.describe]) |
| 43 | parts.push('Sub-Commands:\n' + table(data, { |
| 44 | border: getBorderCharacters('void'), |
| 45 | columnDefault: { |
| 46 | paddingLeft: 0, |
| 47 | paddingRight: 1, |
| 48 | }, |
| 49 | drawHorizontalLine: () => false, |
| 50 | })) |
| 51 | } |
| 52 | return parts.join('\n\n') |
| 53 | } |
no test coverage detected