Skip to content

map Functions

🛠️ Tools · ⬅ Top


Mapping in this context refers to replacing tokens in a file from one value to another; useful for simple templates and configuration customizations.

mapEnvironment

Convert tokens in files to environment variable values

Arguments

  • --help - Optional. Flag. Display this help.
  • environmentVariableName - Optional. String. Map this value only. If not specified, all environment variables are mapped.
  • --prefix - Optional. String. Prefix character for tokens, defaults to {.
  • --suffix - Optional. String. Suffix character for tokens, defaults to }.
  • --search-filter - Zero or more. Callable. Filter for search tokens. (e.g. lowercase)
  • --replace-filter - Zero or more. Callable. Filter for replacement strings. (e.g. trimSpace)

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Environment

  • Argument-passed or entire environment variables which are exported are used and mapped to the destination.

Requires

environmentVariables cat throwEnvironment catchEnvironment throwArgument decorate usageArgumentString

mapValue

Maps a string using an environment file

Usage

mapValue mapFile [ value ... ]

Maps a string using an environment file

Arguments

  • --help - Optional. Flag. Display this help.
  • --handler handler - Optional. Function. Use this error handler instead of the default error handler.
  • mapFile - Required. File. a file containing bash environment definitions
  • value - Optional. String. One or more values to map using said environment file
  • --prefix - Optional. String. Token prefix defaults to {.
  • --suffix - Optional. String. Token suffix defaults to }.
  • --search-filter - Zero or more. Callable. Filter for search tokens. (e.g. lowercase)
  • --replace-filter - Zero or more. Callable. Filter for replacement strings. (e.g. trimSpace)

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

mapValueTrim

Maps a string using an environment file

Usage

mapValueTrim mapFile [ value ... ]

Maps a string using an environment file

Arguments

  • mapFile - Required. File. a file containing bash environment definitions
  • value - Optional. String. One or more values to map using said environment file.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

isMappable

Check if text contains mappable tokens

Usage

isMappable [ --help ] [ --prefix ] [ --suffix ] [ --token ] [ text ]

Check if text contains mappable tokens If any text passed contains a token which can be mapped, succeed. Return code: - 0 - Text contains mapping tokens Return code: - 1 - Text does not contain mapping tokens

Arguments

  • --help - Optional. Flag. Display this help.
  • --prefix - Optional. String. Token prefix defaults to {.
  • --suffix - Optional. String. Token suffix defaults to }.
  • --token - Optional. String. Classes permitted in a token
  • text - Optional. String. Text to search for mapping tokens.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

mapTokens

Short description: list mappable variables in a file (without prefix

Usage

mapTokens prefix suffix < input > output

Short description: list mappable variables in a file (without prefix or suffix)

Arguments

  • prefix - Optional prefix for token search, defaults to { (same as map.sh)
  • suffix - Optional suffix for token search, defaults to } (same as map.sh)

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Environment

  • None.