#!/bin/bash
# The purpose of these functions is to have a lighter implimentation for the use of the environment file so that a user can run the scriptsby hand if need be

# tkis_local_pop will do nothing for a user by hand
tkis_local_pop(){
  echo
}

tkis_local_push(){
  if [[ $1 == "" ]] ; then
    echo "tkis_local_push(): first parameter is empty and should be either absolute, program, or work"
    sleep 2
    return 1
  fi

  if [[ $2 == "" && $1 != "work" && $1 != "program" ]] ; then
    echo "tkis_local_push(): second parameter is empty and needs to be a directory"
    sleep 2
    return 1
  fi

  if [[ $1 == "absolute" ]] ; then
    cd $2
  elif [[ $1 == "work" ]] ; then
    cd ${WO}$2
  elif [[ $1 == "program" ]] ; then
    echo "Warning: Because you are running this function by hand, the script has no way of knowing what the program is, let alone its directory"
    echo "Please manually change into $WO/NAME_OF_THE_PROGRAM/$2, where NAME_OF_THE_PROGRAM is the directory for the program you are working on"
    sleep 2
    return 1
  else
    echo "tkis_local_push(): first parameter is not and must be one of the following: absolute, program, or work"
    sleep 2
    return 1
  fi
}

tkis_local_get_version(){
  echo "tkis_local_get_version(): Please export LOCAL_VERSION=VERSION_OF_THE_PROGRAM, where the program is '$1' and VERSION_F_THE_PROGRAM is the version of '$1' to be used"
  sleep 2
  return 1
}


# If a script requires the use of certain non-standard parameters that may or may not be defined, make sure they get defined
tkis_local_require(){
  for i in $* ; do
    if [[ $(eval "echo \$$i") == "" ]] ; then
      echo "The variable $i is not defined, define it now:"
      echo -e -n "$i = "
      read $i
      eval "export $i"
    fi
  done
}
