#!/usr/bin/env bash

function __shellops__tool_version() {
  local tool="$1"
  # shellcheck disable=SC2154
  if [[ -n "${SHELLOPS_TOOL_REQUIREMENTS:-}" ]]; then
    jq_get "$SHELLOPS_TOOL_REQUIREMENTS" '.version'
    return 0
  fi
  if [[ -n "${__tools_api__registry:-}" ]]; then
    jq_get "$__tools_api__registry" ".\"$tool\".version"
    return 0
  fi
  error "__shellops__tool_version: missing SHELLOPS_TOOL_REQUIREMENTS or __tools_api__registry (tool '$tool')"
  return 1
}
