#!/bin/bash

# Get any leading options from the arguments.  (There are none at this time.)
# If there is an unrecognized option, set needHelp.
#
needHelp=0

token=${1:-foo}

while [ ${token:0:1} == "-" ] ; do
    case $1 in 
        * ) needHelp=1 ;;
    esac

    shift

    token=${1:-foo}
done

# There should be two arguments.  If that is not true, set needHelp.
#
if (( $# != 2 )) ; then
    needHelp=1
fi

# If help is needed, write a usage message and exit.
#
if [ $needHelp == 1 ] ; then
    echo
    echo 'Usage: TSVtoNcML <input file> <output file>'
    echo
    echo '    The input file must be a TSV (tab separated values) file.'
    echo '    The output file will be an NcML file.'

    exit 1
fi

# Get the folder where the awk script is found.
#
dirbase=`dirname $0`

# Run the awk script.
#
gawk -f $dirbase/TSVtoNcML.awk $1 > $2
