mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-18 15:04:17 +00:00
31 lines
658 B
JavaScript
31 lines
658 B
JavaScript
export default async function buildCommands(commands, program) {
|
|
for await (const command of commands) {
|
|
if (typeof command.fn !== "function") {
|
|
continue
|
|
}
|
|
|
|
const commandInstance = program.command(command.cmd).action(command.fn)
|
|
|
|
if (command.description) {
|
|
commandInstance.description(command.description)
|
|
}
|
|
|
|
if (command.options) {
|
|
for (const option of command.options) {
|
|
commandInstance.option(option.option, option.description)
|
|
}
|
|
}
|
|
|
|
if (command.arguments) {
|
|
for (const argument of command.arguments) {
|
|
commandInstance.argument(
|
|
argument.argument,
|
|
argument.description,
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
return program
|
|
}
|