(componentName: string)
| 83 | res && res.outputHelp(); |
| 84 | } |
| 85 | private async singleComponentHelp(componentName: string) { |
| 86 | const { projectName, command } = this.spec; |
| 87 | const instance = await loadComponent(componentName, { logger }); |
| 88 | const data = get(instance, `commands.${command}`); |
| 89 | if (isEmpty(data)) { |
| 90 | logger.info('The help information of the component is not obtained'); |
| 91 | return; |
| 92 | } |
| 93 | const description = get(data, 'help.description'); |
| 94 | let customProgram = projectName ? this.program.command(projectName).command(command) : this.program.command(command); |
| 95 | customProgram.description(description).summary(get(data, 'help.summary', description)).option('-h, --help', 'Display help for command', undefined); // 手动调用help信息 |
| 96 | each(get(data, 'help.option', []), item => { |
| 97 | const [start, ...rest] = item; |
| 98 | customProgram.option(start, ...rest); |
| 99 | }); |
| 100 | each(get(data, 'subCommands', {}), (item, key) => { |
| 101 | const desc = get(item, 'help.description'); |
| 102 | customProgram.command(key).description(desc).summary(get(item, 'help.summary', desc)).option('-h, --help', 'Display help for command', undefined); // 手动调用help信息 |
| 103 | }); |
| 104 | const argv = process.argv.slice(2); |
| 105 | const { _: raw } = parseArgv(argv); |
| 106 | const subCommand = filter(raw, o => !includes([projectName, command], o)); |
| 107 | if (isEmpty(subCommand)) return customProgram; |
| 108 | |
| 109 | const subCommandInfo = get(data, `subCommands.${subCommand}`, {}); |
| 110 | const subDescription = get(subCommandInfo, 'help.description'); |
| 111 | const subCustomProgram = customProgram |
| 112 | .command(first(subCommand)) |
| 113 | .description(subDescription) |
| 114 | .summary(get(subCommandInfo, 'help.summary', subDescription)) |
| 115 | .option('--env <envName>', '[Optional] Specify the env name') // 可选 env和skip-actions |
| 116 | .option('--skip-actions', '[Optional] Skip the extends section') |
| 117 | .option('-h, --help', 'Display help for command', undefined); // 手动调用help信息 |
| 118 | each(get(subCommandInfo, 'help.option', []), item => { |
| 119 | const [start, ...rest] = item; |
| 120 | subCustomProgram.option(start, ...rest); |
| 121 | }); |
| 122 | return subCustomProgram; |
| 123 | } |
| 124 | private async multiComponentHelp() { |
| 125 | const { steps } = this.spec; |
| 126 | for (const item of steps) { |
no outgoing calls
no test coverage detected