<commit_before>#!/bin/sh

# Automatic AUR interaction.
#
# This is a thin, flimsy convenience function that should only be used to
# install a real AUR helper, such as 'paru' or 'aura'. They handle installation,
# upgrading, downgrading, and dependency resolution MUCH better than this
# function.
aur() {
  local aurCommand
  local options

  _aur_help() {
    command cat <<EOF
${FUNCNAME[1]} - Manage packages from the Arch User Repositories \(AUR\)

'aur' is a CLI tool for interacting with the AUR. You may use 'aur' to  install,
update, and remove packages from the AUR automatically.

USAGE
  ${FUNCNAME[1]} [-h|--help]
                 [get|install|update|remove|uninstall] package [package ...]

COMMANDS
  get [PACKAGES]
    Downloads package repositories from the AUR but does not build or install
    them.

  install [PACKAGES]
    Installs one or more packages from the AUR to ${AUR_HOME}.

  update [PACKAGES]
    Updates one or more AUR packages installed to ${AUR_HOME}.

  remove [PACKAGES]
  uninstall [PACKAGES]
    Removes one or more AUR packages installed to ${AUR_HOME}.
EOF
  }

  options="$(getopt -o h -l help -- "$@")"
  eval set -- "$options"
  while true; do
    case "$1" in
    -h | --help)
      _aur_help
      return 0
      ;;

    --)
      shift
      break
      ;;

    *)
      err "Unknown argument $1 to ${FUNCNAME[0]}"
      return 2
      ;;
    esac
  done

  __prepare_aur_environment
  aurCommand="$1"
  shift
  case "$aurCommand" in
  "get")
    __aur_get "$@"
    ;;
  "install")
    __aur_get "$@" &&
      __aur_install "$@"
    ;;
  "update")
    _aur_update "$@"
    ;;
  "remove" | "uninstall")
    __aur_remove "$@"
    ;;
  *)
    err "Unknown AUR command ${RED}${aurCommand}${NC}. Should be one of:" \
      "install, update, remove."
    return 1
    ;;
  esac
}

# Install an AUR package manager for the Arch Linux User Repository.
install_aur_helper() {
  if [ ! -x "$(command -v "${AUR_HELPER}")" ]; then
    aur install "${AUR_HELPER}"
  else
    warn "AUR helper ${BLUE}${AUR_HELPER}${NC} already installed."
  fi
}

# Install all AUR packages
install_aur_packages() {
  if [ ! -x "$(command -v "${AUR_HELPER}")" ]; then
    install_aur_helper
  fi
  aurhinc $(grep -E -v "^\s*#" "${AUR_PACKAGES_FILE}" | tr '\n' ' ')
}

get_aur_packages() {
  aur get <"${AUR_PACKAGES_FILE:?}"
}

# Update all packages installed with the AUR helper tool.
# This funcion allows users to ignore certain packages, as well.
# For instance, for Emacs, we typically want to download the PKGBUILD
# file with `paru -G emacs-native-comp-git-enhanced` so we can edit it, then
# install it manually with `makepkg -si`.
aurupdate() {
  local ignorePackages=(
    "emacs-native-comp-git-enhanced"
  )

  aurhu --ignore="$(echo "${ignorePackages[*]}" | sed -E 's/ +/,/')"
}

# Download an AUR package but do not build/install
__aur_get() {
  # Get args from stdin if none are passed as args
  set -- ${*:-$(</dev/stdin)}
  echoe "Have $# requests: $*"

  local -a newPackages=($(__get_list_of_new_packages "$@"))<commit_msg>Small change<commit_after>#!/bin/sh

# Automatic AUR interaction.
#
# This is a thin, flimsy convenience function that should only be used to
# install a real AUR helper, such as 'paru' or 'aura'. They handle installation,
# upgrading, downgrading, and dependency resolution MUCH better than this
# function.
aur() {
  local aurCommand
  local options

  _aur_help() {
    command cat <<EOF
${FUNCNAME[1]} - Manage packages from the Arch User Repositories \(AUR\)

'aur' is a CLI tool for interacting with the AUR. You may use 'aur' to  install,
update, and remove packages from the AUR automatically.

USAGE
  ${FUNCNAME[1]} [-h|--help]
                 [get|install|update|remove|uninstall] package [package ...]

COMMANDS
  get [PACKAGES]
    Downloads package repositories from the AUR but does not build or install
    them.

  install [PACKAGES]
    Installs one or more packages from the AUR to ${AUR_HOME}.

  update [PACKAGES]
    Updates one or more AUR packages installed to ${AUR_HOME}.

  remove [PACKAGES]
  uninstall [PACKAGES]
    Removes one or more AUR packages installed to ${AUR_HOME}.
EOF
  }

  options="$(getopt -o h -l help -- "$@")"
  eval set -- "$options"
  while true; do
    case "$1" in
    -h | --help)
      _aur_help
      return 0
      ;;

    --)
      shift
      break
      ;;

    *)
      err "Unknown argument $1 to ${FUNCNAME[0]}"
      return 2
      ;;
    esac
  done

  __prepare_aur_environment
  aurCommand="$1"
  shift
  case "$aurCommand" in
  "get")
    __aur_get "$@"
    ;;
  "install")
    __aur_get "$@" &&
      __aur_install "$@"
    ;;
  "update")
    _aur_update "$@"
    ;;
  "remove" | "uninstall")
    __aur_remove "$@"
    ;;
  *)
    err "Unknown AUR command ${RED}${aurCommand}${NC}. Should be one of:" \
      "install, update, remove."
    return 1
    ;;
  esac
}

# Install an AUR package manager for the Arch Linux User Repository.
install_aur_helper() {
  if [ ! -x "$(command -v "${AUR_HELPER}")" ]; then
    aur install "${AUR_HELPER}"
  else
    warn "AUR helper ${BLUE}${AUR_HELPER}${NC} already installed."
  fi
}

# Install all AUR packages
install_aur_packages() {
  if [ ! -x "$(command -v "${AUR_HELPER}")" ]; then
    install_aur_helper
  fi
  aurhinc $(grep -E -v "^\s*#" "${AUR_PACKAGES_FILE}" | tr '\n' ' ')
}

get_aur_packages() {
  aur get <"${AUR_PACKAGES_FILE:?}"
}

# Update all packages installed with the AUR helper tool.
# This funcion allows users to ignore certain packages, as well.
# For instance, for Emacs, we typically want to download the PKGBUILD
# file with `paru -G emacs-native-comp-git-enhanced` so we can edit it, then
# install it manually with `makepkg -si`.
aurupdate() {
  local ignorePackages=(
    "emacs-native-comp-git-enhanced"
  )

  aurhu --ignore="$(echo "${ignorePackages[*]}" | sed -E 's/\s+/,/')"
}

# Download an AUR package but do not build/install
__aur_get() {
  # Get args from stdin if none are passed as args
  set -- ${*:-$(</dev/stdin)}
  echoe "Have $# requests: $*"

  local -a newPackages=($(__get_list_of_new_packages "$@"))
{'fraction_non_alphanumeric': 0.13484798953906504, 'fraction_numerical': 0.002942137953579601, 'mean_word_length': 3.009829619921363, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '528625', 'n_tokens_mistral': 2141, 'n_tokens_neox': 2036, 'n_words': 683}