<commit_before>#!/usr/bin/env bash

# TODO: Refectory to use a common functions
azk.debug.color() {
  case "${1}" in
    info)
      echo "%{blue}"
      ;;
    error)
      echo "%{red}"
  esac
}

# TODO: Cache this
azk.tput() {
  [ -z "$TERM" ] && return 0
  eval "tput $@"
}

azk.escape() {
  echo "$@" | sed "
    s/%{red}/$(azk.tput setaf 1)/g;
    s/%{green}/$(azk.tput setaf 2)/g;
    s/%{yellow}/$(azk.tput setaf 3)/g;
    s/%{blue}/$(azk.tput setaf 4)/g;
    s/%{magenta}/$(azk.tput setaf 5)/g;
    s/%{cyan}/$(azk.tput setaf 6)/g;
    s/%{white}/$(azk.tput setaf 7)/g;
    s/%{reset}/$(azk.tput sgr0)/g;
    s/%{[a-z]*}//g;
  "
}

azk.debug() {
  local nivel="$1"; shift
  local color="$(azk.debug.color "$nivel")"
  echo "$(azk.escape "${color}azk%{reset}:$AZK_DEBUG_PREFIX $@")" >&2
}

azk.info() {
  azk.debug info "$@"
}

azk.error() {
  azk.debug error "$@"
}

azk.render() {
eval "cat <<EOF
$(echo -en "$1")
EOF
" 2> /dev/null
}

azk.is_parameter() {
  # zero length not is parameter
  [ -z "$1" ] && return 1;

  # -[alpha] --[alpha] is parameter
  [[ "$1" =~ ^--?[a-zA-Z0-9]{1,}$ ]] && return 0;

  return 1;
}

azk.docker_containers() {
  local image=$(azk-provision --get-name app)
  local filter=". | map(select(.Image | contains(\"$image\")))"
  azk-dcli /containers/json | jq -r "$filter"
}

azk.uuid() {
  local size="${1:-32}"
  printf "%.${size}s" "$(uuidgen | sed 's:\-::g' | awk '{print tolower($0)}')"
}

azk.redis() {
  exec 6<>/dev/tcp/azk-agent/49229
  if [ $? -ne 0 ]; then
    azk.error "[redis] dont connect to redis"
    exit 1
  fi
  redis-client "$@"
}<commit_msg>Force use local redis ip.<commit_after>#!/usr/bin/env bash

# TODO: Refectory to use a common functions
azk.debug.color() {
  case "${1}" in
    info)
      echo "%{blue}"
      ;;
    error)
      echo "%{red}"
  esac
}

# TODO: Cache this
azk.tput() {
  [ -z "$TERM" ] && return 0
  eval "tput $@"
}

azk.escape() {
  echo "$@" | sed "
    s/%{red}/$(azk.tput setaf 1)/g;
    s/%{green}/$(azk.tput setaf 2)/g;
    s/%{yellow}/$(azk.tput setaf 3)/g;
    s/%{blue}/$(azk.tput setaf 4)/g;
    s/%{magenta}/$(azk.tput setaf 5)/g;
    s/%{cyan}/$(azk.tput setaf 6)/g;
    s/%{white}/$(azk.tput setaf 7)/g;
    s/%{reset}/$(azk.tput sgr0)/g;
    s/%{[a-z]*}//g;
  "
}

azk.debug() {
  local nivel="$1"; shift
  local color="$(azk.debug.color "$nivel")"
  echo "$(azk.escape "${color}azk%{reset}:$AZK_DEBUG_PREFIX $@")" >&2
}

azk.info() {
  azk.debug info "$@"
}

azk.error() {
  azk.debug error "$@"
}

azk.render() {
eval "cat <<EOF
$(echo -en "$1")
EOF
" 2> /dev/null
}

azk.is_parameter() {
  # zero length not is parameter
  [ -z "$1" ] && return 1;

  # -[alpha] --[alpha] is parameter
  [[ "$1" =~ ^--?[a-zA-Z0-9]{1,}$ ]] && return 0;

  return 1;
}

azk.docker_containers() {
  local image=$(azk-provision --get-name app)
  local filter=". | map(select(.Image | contains(\"$image\")))"
  azk-dcli /containers/json | jq -r "$filter"
}

azk.uuid() {
  local size="${1:-32}"
  printf "%.${size}s" "$(uuidgen | sed 's:\-::g' | awk '{print tolower($0)}')"
}

azk.redis() {
  exec 6<>/dev/tcp/12172.16.58.3/49229
  if [ $? -ne 0 ]; then
    azk.error "[redis] dont connect to redis"
    exit 1
  fi
  redis-client "$@"
}
{'fraction_non_alphanumeric': 0.2506211180124224, 'fraction_numerical': 0.02422360248447205, 'mean_word_length': 2.7453488372093022, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1837956', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1432, 'n_words': 296}