INNER CODE UNIT · TypeScript

createHelpConfiguration

lmstudio-ai/lms · src/index.ts:110

function createHelpConfiguration(maxWidth: number, helpMessageGap: number): HelpConfiguration {
  return {
    helpWidth: maxWidth,
    commandUsage: command => chalk.bold(`${getCommandPath(command)} ${command.usage()}`),
    subcommandTerm: (command: CommandUnknownOpts) => formatCommandTerm(command, helpMessageGap),
    subcommandDescription: (command: { description(): string }) => command.description(),
    visibleOptions: command =>
      command.options.filter(
        option => option.long !== "--help" && option.short !== "-h" && option.hidden !== true,
      ),
    optionTerm: (option: { flags: string }) =>
      chalk.cyan(dimOptionParameters(option.flags, helpMessageGap)),
    optionDescription: (option: { description?: string }) => option.description ?? "",
    argumentTerm: (argument: { name(): string }) => {
      const argumentName = argument.name();
      const paddedName = argumentName.padEnd(argumentName.length + helpMessageGap, " ");
      return `${" ".repeat(HELP_MESSAGE_PADDING_LEFT)}${paddedName}`;
    },

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…