#!/usr/bin/qsh
#
# //  DESCRIPTION:
# //      

. $(/usr/bin/dirname $0)/setupCmdLine

printUsage()
{
  echo "wrd-config -workspace <workspace name> -project <projectID> -style <styleID> [<optional parameters>]"
  echo " "
  echo " Required Parameters:"
  echo "   workspace      - The target workspace name. This parameter is required only if the WORKSPACE "
  echo "                    variable is not set."
  echo "   project        - The target project."
  echo "   style          - Deployment style."
  echo " "
  echo " Optional Parameters:"
  echo "   rebuild        - Issues a clean and rebuild."
  echo "   configure      - Prompts configuration."
  echo "   runtime        - Target runtime server."
  echo "   runtimePath    - Target runtime server path."
  echo "   j2eeVersion    - J2EE version ID."
  echo "   configData     - External configuration file."
  echo "   configPath     - Configuration file location."
  echo "   listStyles     - Displays available deployment styles."
  echo " "
  echo "Available Rapid Deployment Styles"
  echo "  Configuration ID: AutoAppInstall"
  echo "  Name: Auto Application Install"
  echo "  Description: This style automates the installation of a packaged EAR or J2EE Module file onto a WebSphere Server."
  echo " "
  echo "  Configuration ID: FreeForm"
  echo "  Name: WebSphere Free Form Project"
  echo "  Description: This style constructs a full J2EE application by processing individual parts within a single repository."
}

PASSPARM=""

while [ $# -gt 0 ]; do
  case $1 in
        -help)
               printUsage
               exit 0
               ;;
        -?)
               printUsage
               exit 0
               ;;
        -workspace) shift
                    WORKSPACE="$1"
                    ;;
        -project) shift
                  PROJECT="$1"
                  ;;
        -style) shift
                STYLE="$1"
                ;;
        *) PASSPARM="$PASSPARM $1"
            ;;
  esac
  shift
done

if [ -z "$WORKSPACE" ] || [ -z "$PROJECT" ] || [ -z "$STYLE" ]; then
  printUsage
  exit 0
fi

CP=${ITP_LOC}/startup.jar
APPLICATION=com.ibm.ws.rapiddeploy.core.WRDExec

${JAVA_HOME}/bin/java ${JAVA_FLAGS} \
  -classpath ${CP} \
  org.eclipse.core.launcher.Main -noupdate -data ${WORKSPACE} -application ${APPLICATION} -config -project ${PROJECT} -style ${STYLE} ${PASSPARM}
