#!/usr/bin/env bash

set -e

basedir=$(dirname $0)
reinit_flag=$basedir/reinit
PATH+=:~/.local/bin

command_available() {
  local cmd=$1
  command -v $cmd >/dev/null
}

env_exists() {
  pipenv --venv >/dev/null 2>&1
}

# ensure pipenv available
if ! command_available pipenv >/dev/null; then
  echo "installing 'pipenv'"
  pip3 install --user pipenv
fi

# set working dir
cd $basedir


# initialize framework if requested/needed
if [ -f $reinit_flag ] ; then
  echo "reinitializing"
  pipenv --rm || true
  rm $reinit_flag
fi
if ! env_exists; then
  echo "installing env"
  pipenv --three sync
fi

# run samples
exec pipenv run behave $*

#!/usr/bin/env bash

set -e

basedir=$(dirname $0)
reinit_flag=$basedir/reinit
PATH+=:~/.local/bin
PIP=${PIP:-pip3}

command_available() {
  local cmd=$1
  command -v $cmd >/dev/null
}

env_exists() {
  pipenv --venv >/dev/null 2>&1
}

# ensure pipenv available
if ! command_available pipenv >/dev/null; then
  echo "installing 'pipenv'"
  $PIP install --user pipenv
fi

# set working dir
cd $basedir


# initialize framework if requested/needed
if [ -f $reinit_flag ] ; then
  echo "reinitializing"
  pipenv --rm || true
  rm $reinit_flag
fi
if ! env_exists; then
  echo "installing env"
  pipenv --three sync
fi

# run samples
exec pipenv run behave $*

Allow pip executable to be specified
Allow pip executable to be specified
