#!/bin/bash

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

#forcing the current working directory to our parent
cd "$DIR"/..

# necessary to handle ROS arguments ( since ros does not pass it s argument in a standard/readline way )
# until we do this in main cli()
while [[ $# > 0 ]]
do
key="$1"
case $key in
    __*)  # matching basic ros args
    ROSARGS="${ROSARGS:+$ROSARGS} --ros-arg=$key"
    #ros option (multiple)
    shift 1
    ;;
    ~*)  # matching relative remapping ros args
    ROSARGS="${ROSARGS:+$ROSARGS} --ros-arg=$key"
    #ros option (multiple)
    shift 1
    ;;
    *)
    # ignoring (just forward to command call)
    CMD_ARGS="${CMD_ARGS:+$CMD_ARGS} $key"
    shift 1
    ;;
esac
done

set -x

python -tt -m rostful run ${CMD_ARGS} ${ROSARGS}