#!/bin/bash
# 
# The MFExtractor command script
#
#

# if no args specified, show usage
if [ $# = 0 ]; then
  echo "Usage: Extract <url> | <filepath -uri > [-o output-file [-f output-format]]"
  echo "Input can be a filepath or a url. If it's a path, document's URI must be specified."
  echo "Usage examples: "
  echo "      Extract http://www.example.com -o /path/to/output/file"
  echo "      Extract /path/to/input/file -uri http://example.com -o path/to/output/file"
  echo "Arguments"
  echo "      -f <output-format>   Choose one of rdfxml [default], ntriples, turtle"
  echo "      -o <output-file>     If not exist the program writes to stdout"
  echo "      -h Print this help"
  exit 1
fi

# add libs to CLASSPATH
CLASSPATH=${CLASSPATH}:$JAVA_HOME/lib/tools.jar
for f in ./lib/*.jar; do
  CLASSPATH=${CLASSPATH}:$f;
done

JAVA_HEAP_MAX=-Xmx512m 
CLASS=eu.blogforever.mfextractor.Extract

# run it
exec java $JAVA_HEAP_MAX -classpath "$CLASSPATH" $CLASS "$@"
