<commit_before>#!/bin/bash

# Make the script exit on any errors returned by individual commands.
set -e

# Show commands as they get executed
#set -x

# Reset the environmental vars if they're already set.
unset DIR CURRENT_DIR

# Get the correct directory info to use in a bash script and store in variables. I'm using the most-updated way to achieve this.
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CURRENT_DIR="${DIR##*/}"

load_generators() {
  for dagenerator in $(ls $DIR/generators); do
    source $DIR/generators/$dagenerator
    echo "[LOADED]: generators/$dagenerator";
  done
}

get_projname() {
  PROJNAME="datt"
    # # Get the user input.
    # printf "Enter the project name: " ; read -r PROJNAME

    # # Remove the spaces from the title if necessary.
    # PROJNAME=${PROJNAME// /_}

    # # Convert uppercase to lowercase.
    # PROJNAME=${PROJNAME,,}
}

# For dev purposes, a nice helper function to clean out old test files.

clean_old() {
  for files in "build_test.sh" "build.sh"; do
    rm -v "$DIR/../$daproject/$files"
  done
}

generator_run() {
# Determine the project name. This will be the user name for the public docker index, or for a private index it will be the docker index location. For example `localhost:8888/`
  get_projname

# Each subproject has utility scripts that can be generated from templates stored in the templates folder in this repo. I'm expecting that all subprojects are in the same directory. Meta-bash :-)

  for daproject in $(ls $DIR/..); do
    if [[ "$daproject" != "$CURRENT_DIR" ]]; then
      for datemplate in $(ls $DIR/templates); do
        if [[ "$1" == "$datemplate" ]]; then
          # retrieve the passed name without the suffix after the `.`
          command_name=$(echo $1 | cut -d. -f 1)
          # bash is insane. :-) run the appropriate _generator function.
          echo $($command_name"_generator")
          echo "command: $command_name"
        fi
      done
    fi
  done
}

usage() {
  echo "Usage: $0 {-b <templatename>}"
  echo ""
  echo "Examples:"
  for datemplate in $(ls $DIR/templates); do
    echo "metabuild.sh -b $datemplate"
  done
  echo ""

  exit 1
}

# ------------ MAIN STUFF

# load the generators in the `generators` sub-folder
load_generators

# if no arguments are passed, display the help

if [ -z "${1}" ]; then
  usage
  exit 1
fi

# parse command-line options

while getopts ":a:b:h" o; do
  case "${o}" in
    a)
      echo "${o} was triggered, Parameter: ${OPTARG}" >&2
      ;;
    b)
      echo "-b was triggered, Parameter: ${OPTARG}"
      generator_run ${OPTARG}
      ;;
    \?)
      echo "Invalid option: -${OPTARG}"
      exit 1
      ;;
    :)
      echo "Option -${OPTARG} requires an argument."
      exit 1
      ;;
    *)
      usage
      ;;
  esac
done
<commit_msg>bash is not noteworthy in this respect.<commit_after>#!/bin/bash

# Make the script exit on any errors returned by individual commands.
set -e

# Show commands as they get executed
#set -x

# Reset the environmental vars if they're already set.
unset DIR CURRENT_DIR

# Get the correct directory info to use in a bash script and store in variables. I'm using the most-updated way to achieve this.
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CURRENT_DIR="${DIR##*/}"

load_generators() {
  for dagenerator in $(ls $DIR/generators); do
    source $DIR/generators/$dagenerator
    echo "[LOADED]: generators/$dagenerator";
  done
}

get_projname() {
  PROJNAME="datt"
    # # Get the user input.
    # printf "Enter the project name: " ; read -r PROJNAME

    # # Remove the spaces from the title if necessary.
    # PROJNAME=${PROJNAME// /_}

    # # Convert uppercase to lowercase.
    # PROJNAME=${PROJNAME,,}
}

# For dev purposes, a nice helper function to clean out old test files.

clean_old() {
  for files in "build_test.sh" "build.sh"; do
    rm -v "$DIR/../$daproject/$files"
  done
}

generator_run() {
# Determine the project name. This will be the user name for the public docker index, or for a private index it will be the docker index location. For example `localhost:8888/`
  get_projname

# Each subproject has utility scripts that can be generated from templates stored in the templates folder in this repo. I'm expecting that all subprojects are in the same directory. Meta-bash :-)

  for daproject in $(ls $DIR/..); do
    if [[ "$daproject" != "$CURRENT_DIR" ]]; then
      for datemplate in $(ls $DIR/templates); do
        if [[ "$1" == "$datemplate" ]]; then
          # retrieve the passed name without the suffix after the `.`
          command_name=$(echo $1 | cut -d. -f 1)
          # run the appropriate _generator function.
          echo $($command_name"_generator")
          echo "command: $command_name"
        fi
      done
    fi
  done
}

usage() {
  echo "Usage: $0 {-b <templatename>}"
  echo ""
  echo "Examples:"
  for datemplate in $(ls $DIR/templates); do
    echo "metabuild.sh -b $datemplate"
  done
  echo ""

  exit 1
}

# ------------ MAIN STUFF

# load the generators in the `generators` sub-folder
load_generators

# if no arguments are passed, display the help

if [ -z "${1}" ]; then
  usage
  exit 1
fi

# parse command-line options

while getopts ":a:b:h" o; do
  case "${o}" in
    a)
      echo "${o} was triggered, Parameter: ${OPTARG}" >&2
      ;;
    b)
      echo "-b was triggered, Parameter: ${OPTARG}"
      generator_run ${OPTARG}
      ;;
    \?)
      echo "Invalid option: -${OPTARG}"
      exit 1
      ;;
    :)
      echo "Option -${OPTARG} requires an argument."
      exit 1
      ;;
    *)
      usage
      ;;
  esac
done

{'fraction_non_alphanumeric': 0.1265495867768595, 'fraction_numerical': 0.006887052341597796, 'mean_word_length': 2.7671854734111543, 'pattern_counts': {'":': 2, '<': 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': '6363254', 'n_tokens_mistral': 1906, 'n_tokens_neox': 1819, 'n_words': 675}