<commit_before>#
# lib.d/helpers/git.sh for dex -*- shell-script -*-
#

error(){
  [ -z "$1" ] && set -- "general exception. halting..."

  printf "\e[31m%b\n\e[0m" "$@" >&2
  exit ${__error_code:-1}
}

error_noent() {
  __error_code=127
  error "$@"
}

error_perms() {
  __error_code=126
  error "$@"
}

error_exception() {
  __error_code=2
  error "$@"
}


log(){
  printf "\e[33m%b\n\e[0m" "$@" >&2
}

prompt_confirm() {
  while true; do
    echo
    read -r -n 1 -p "  ${1:-Continue?} [y/n]: " REPLY
    case $REPLY in
      [yY]) echo ; return 0 ;;
      [nN]) echo ; return 1 ;;
      *) printf " \033[31m %s \n\033[0m" "invalid input"
    esac
  done
}
<commit_msg>prompts read from /dev/tty<commit_after>#
# lib.d/helpers/git.sh for dex -*- shell-script -*-
#

error(){
  [ -z "$1" ] && set -- "general exception. halting..."

  printf "\e[31m%b\n\e[0m" "$@" >&2
  exit ${__error_code:-1}
}

error_noent() {
  __error_code=127
  error "$@"
}

error_perms() {
  __error_code=126
  error "$@"
}

error_exception() {
  __error_code=2
  error "$@"
}


log(){
  printf "\e[33m%b\n\e[0m" "$@" >&2
}

prompt_echo() {
  while true; do
    echo
    # read always from /dev/tty, use `if [ -t 0 ]` upstream to avoid prompt
    read -r -p "  ${1:-input} : " INPUT </dev/tty
    [ -z "$INPUT" ] || { echo "$INPUT" ; return 0 ; }
    printf " \033[31m %s \n\033[0m" "invalid input"
  done
}

prompt_confirm() {
  while true; do
    echo
    # read always from /dev/tty, use `if [ -t 0 ]` upstream to avoid prompt
    read -r -n 1 -p "  ${1:-Continue?} [y/n]: " REPLY </dev/tty
    case $REPLY in
      [yY]) echo ; return 0 ;;
      [nN]) echo ; return 1 ;;
      *) printf " \033[31m %s \n\033[0m" "invalid input"
    esac
  done
}

{'fraction_non_alphanumeric': 0.20729588882455124, 'fraction_numerical': 0.04226983207874928, 'mean_word_length': 2.4353876739562623, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '3699098', 'n_tokens_mistral': 789, 'n_tokens_neox': 731, 'n_words': 176}