Options
All
  • Public
  • Public/Protected
  • All
Menu

Module cli/utils

Index

Type aliases

Case

Case: "upper" | "lower" | "cap" | "dash" | "snake" | "title" | "dot" | "camel"

ToArrayType

ToArrayType: string | boolean | number

Functions

changeCase

  • changeCase(str: string, casing: Case, preTrim?: boolean): any

createError

  • createError(errOrMessage: string | Error): Error

escapeRegex

  • escapeRegex(str: string): string
  • Escapes a regexp string.

    Parameters

    • str: string

      the string to escape.

    Returns string

filterOptions

  • filterOptions(keys: string[], options: Record<string, any>): {}
  • Removes unnecessary keys.

    Parameters

    • keys: string[]

      the keys to filter/remove.

    • options: Record<string, any>

      the object to be filtered.

    Returns {}

parseCommand

  • parseCommand(arg: string): { args: string[]; command: string }[]
  • Parses a command looking up wildcards when present.

    Parameters

    • arg: string

      the complete unparsed argument/command.

    Returns { args: string[]; command: string }[]

simpleFormatter

  • simpleFormatter<R>(str: string, obj: R, exp?: RegExp): string
  • simpleFormatter<R>(str: string[], obj: R, exp?: RegExp): string[]
  • Formats string matching template expression replacing with key values in object.

    Type parameters

    • R: Record<string, string>

    Parameters

    • str: string

      the string to be formated.

    • obj: R

      the object to use for mapping values.

    • Optional exp: RegExp

    Returns string

  • Formats strings matching template expression replacing with key values in object.

    Type parameters

    • R: Record<string, string>

    Parameters

    • str: string[]

      the string to be formated.

    • obj: R

      the object to use for mapping values.

    • Optional exp: RegExp

    Returns string[]

stylizer

  • stylizer(str: string, style: string | keyof StyleFunction, ...styles: keyof StyleFunction[]): string
  • Colorizes a string.

    Parameters

    • str: string

      the string to be stylized.

    • style: string | keyof StyleFunction

      a style or dot notation string of styles.

    • Rest ...styles: keyof StyleFunction[]

      rest param of styles.

    Returns string

toArray

  • toArray<T>(value: any, def?: any[]): T[]
  • Ensures value is an array.

    Type parameters

    • T = string

    Parameters

    • value: any

      the value to ensure as array.

    • def: any[] = []

      the default value if undefined or null.

    Returns T[]

toCommands

  • Builds commands into configuration for Spawnmon.

    Parameters

    • commands: string[]

      takes string commands to parse.

    • Optional options: Record<string, any>

    Returns ICommandOptionsExt[]

toConfig

toFlag

  • toFlag(value: string): string
  • toFlag(...values: string[]): string[]
  • Converts a property to a cli flag.

    Parameters

    • value: string

    Returns string

  • Converts a properties to a cli flags.

    Parameters

    • Rest ...values: string[]

      the values to convert to flags.

    Returns string[]

toYargsOptions

  • toYargsOptions(items: HelpConfigs, configuration?: Partial<Configuration>): { aliases: any[]; options: { alias: any; array: any[]; boolean: any[]; coerce: any; configuration: Partial<Configuration>; default: any; number: any[]; string: any[] } }
  • Converts help config objects to Yargs Parser config objects.

    Parameters

    • items: HelpConfigs
    • configuration: Partial<Configuration> = {}

    Returns { aliases: any[]; options: { alias: any; array: any[]; boolean: any[]; coerce: any; configuration: Partial<Configuration>; default: any; number: any[]; string: any[] } }

    • aliases: any[]
    • options: { alias: any; array: any[]; boolean: any[]; coerce: any; configuration: Partial<Configuration>; default: any; number: any[]; string: any[] }
      • alias: any
      • array: any[]
      • boolean: any[]
      • coerce: any
      • configuration: Partial<Configuration>
      • default: any
      • number: any[]
      • string: any[]

unflag

  • unflag(value: string): string
  • Removes either -- or - from value.

    Parameters

    • value: string

      the value to unflag

    Returns string

Generated using TypeDoc