#!/usr/bin/env bash

# test the presence of the interactive flag
interactive=false
for var in "$@" 
do
    if [ $var == "-i" ]; then
	echo 'interactive mode'
	interactive=true
    fi
done

bindir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

if [ "$interactive" = true ]; then
    args=`echo $@ | sed -e 's#-i##g'`
    ln -sf $bindir/heppy_interactive.py tmp_heppy.py
    ipython -i tmp_heppy.py -- $args
else
    echo $heppy
    ln -sf $bindir/heppy_loop.py tmp_heppy.py
    ipython -- tmp_heppy.py "$@"
fi 
rm tmp_heppy.py
