#!/usr/bin/env bash
#
# Summary: Set or show the global Java options
#
# Usage: jenv global-options <options>
#
# Sets the global Java options. You can override the global options at
# any time by setting a directory-specific options with `jenv local-options'
# or by setting the `JENV_OPTIONS' environment variable.
#

set -e
[ -n "$JENV_DEBUG" ] && set -x


JENV_OPTIONS="$1"
JENV_OPTIONS_FILE="${JENV_ROOT}/options"

if [ "$JENV_OPTIONS" = "--unset" ]; then
  rm -f "$JENV_OPTIONS_FILE"
elif [ -n "$JENV_OPTIONS" ]; then
  jenv-options-file-write "$JENV_OPTIONS_FILE" "$JENV_OPTIONS"
else
  jenv-options-file-read "$JENV_OPTIONS_FILE"
fi
