UNPKG

@lodestar/utils

Version:

Utilities required across multiple lodestar packages

26 lines 980 B
/** * Register a CliCommand type to yargs. Recursively registers subcommands too. * @param yargs * @param cliCommand */ // biome-ignore lint/suspicious/noExplicitAny: We need to use `any` type here export function registerCommandToYargs(yargs, cliCommand) { yargs.command({ command: cliCommand.command, describe: cliCommand.describe, builder: (yargsBuilder) => { yargsBuilder.options(cliCommand.options ?? {}); for (const subcommand of cliCommand.subcommands ?? []) { registerCommandToYargs(yargsBuilder, subcommand); } if (cliCommand.examples) { for (const example of cliCommand.examples) { yargsBuilder.example(`$0 ${example.command}`, example.description ?? ""); } } return yargs; }, handler: cliCommand.handler ?? function emptyHandler() { }, }); } //# sourceMappingURL=command.js.map