2024-05-29 11:51:04 -04:00

21 lines
701 B
JavaScript

import utils from '@serverlessinc/sf-core/src/utils.js'
import renderOptionsHelp from './options.js'
import generateCommandUsage from './generate-command-usage.js'
const { writeText } = utils
export default ({ commandName, commandsSchema }) => {
const commandSchema = commandsSchema.get(commandName)
if (commandSchema) {
writeText(generateCommandUsage(commandName, commandSchema))
}
for (const [subCommandName, subCommandSchema] of commandsSchema) {
if (!subCommandName.startsWith(`${commandName} `)) continue
writeText(generateCommandUsage(subCommandName, subCommandSchema))
}
if (commandSchema) renderOptionsHelp(Object.assign({}, commandSchema.options))
writeText()
}