Skip to content

Function signatures for callbacks

🛠️ Tools · ⬅ Home


errorHandler signature

The following function signatures are used prevalently as callbacks:

  • errorHandler - Used by 99% of functions to handle or display errors

errorHandler

The main error handler signature used in Zesk Build.

Usage

errorHandler exitCode [ message ... ]

The main error handler signature used in Zesk Build. Example: Here, handler is a string variable which references our errorHandler function – when used in your code: Example

Arguments

  • exitCode - Integer. Required. The exit code to handle.
  • message ... - EmptyString. Optional. The message to display to the user about what caused the error.

Examples

tempFile=$(fileTemporaryName "$handler") || return $?
catchEnvironment "$handler" rm -f "$tempFile" || return $?
muzzle validate "$handler" Executable "${FUNCNAME[0]} requirements" curl sftp || return $?

Return codes

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

Installation function signatures

These are all used in _installRemotePackage.

packageVersionFunction

Used to check the remote version against the local version

Usage

packageVersionFunction handler applicationHome installPath [ fixedVersion ]

Used to check the remote version against the local version of a package to be installed. versionFunction should exit 0 to halt the installation, in addition it should output the current version as a decorated string.

Writes to standard output

version information

Arguments

  • handler - Function. Required. Function to call when an error occurs. Signature errorHandler.
  • applicationHome - Directory. Required. Path to the application home where target will be installed, or is installed. (e.g. myApp/)
  • installPath - Directory. Required. Path to the installPath home where target will be installed, or is installed. (e.g. myApp/bin/build)
  • fixedVersion - EmptyString. Optional. If a fixed version is requested this is the requested version.

Return codes

  • 0 - Do not upgrade, version is same as remote (stdout is found, current version)
  • 1 - Do upgrade, version changed. (stdout is version change details)

packageUrlFunction

Prints the remote URL for a package, or exits non-zero

Usage

packageUrlFunction handler

Prints the remote URL for a package, or exits non-zero on error. Takes a single argument, the error handler, a function.

Arguments

  • handler - Function. Required. Function to call when an error occurs.

Return codes

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

packageCheckFunction

Verify an installation afterwards.

Usage

packageCheckFunction handler installPath

Verify an installation afterwards. If checkFunction fails, it should output any errors to stderr and return a non-zero exit code.

Arguments

  • handler - Function. Required. Function to call when an error occurs.
  • installPath - Directory. Required. Path to the installPath home where target will be installed, or is installed. (e.g. myApp/bin/build)

Return codes

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