Austen 158f644cd0
feat: Refactor logging to reduce complexity (#12432)
* chore: Change logger

* chore: continue refactor

* chore: WIP

* chore: Sync
2024-04-17 13:26:31 -07:00

21 lines
712 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();
};