#!/bin/sh 

# Shell front end to invoke Funes
# Usage: 
#   funes index foo.mbox bar.mbox
#   funes search some Lucene query

# Variables to edit
FUNESHOME=.
FUNESJAR=$FUNESHOME/build/funes.jar
LIBDIR=$FUNESHOME/lib

# Build a classpath
libjars=`echo $LIBDIR/*.jar | tr ' ' :`
if [ ! -f "$FUNESJAR" ]; then
    echo "$FUNESJAR not found; did you build it with ant?"
    exit 1;
fi
funescp=$FUNESJAR:$libjars:.

# Choose class to invoke based on argument
if [ -n "$1" ] && [ "index" = "$1" ]; then
    class=org.monkey.nelson.funes.Index
elif [ -n "$1" ] && [ "search" = "$1" ]; then
    class=org.monkey.nelson.funes.Search
else
    echo "Usage: funes [index|search] args"
    exit 1;
fi

# Invoke java with our arguments
shift
java -classpath $funescp $class "$@"
