mirror of https://github.com/sbt/sbt.git
support GNU style double dash options
This commit is contained in:
parent
e1aaeb907c
commit
56f09ef1ec
|
|
@ -28,6 +28,12 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
|
|||
()
|
||||
}
|
||||
|
||||
test("sbt --no-colors") {
|
||||
val out = sbtProcess("compile --no-colors -v").!!.linesIterator.toList
|
||||
assert(out.contains[String]("-Dsbt.log.noformat=true"))
|
||||
()
|
||||
}
|
||||
|
||||
test("sbt -mem 503") {
|
||||
val out = sbtProcess("compile -mem 503 -v").!!.linesIterator.toList
|
||||
assert(out.contains[String]("-Xmx503m"))
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ CYGWIN_FLAG=$(if is_cygwin; then echo true; else echo false; fi)
|
|||
# windows style paths.
|
||||
cygwinpath() {
|
||||
local file="$1"
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then #"
|
||||
echo $(cygpath -w $file)
|
||||
else
|
||||
echo $file
|
||||
|
|
@ -387,7 +387,7 @@ run() {
|
|||
copyRt
|
||||
|
||||
#If we're in cygwin, we should use the windows config, and terminal hacks
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then #"
|
||||
stty -icanon min 1 -echo > /dev/null 2>&1
|
||||
addJava "-Djline.terminal=jline.UnixTerminal"
|
||||
addJava "-Dsbt.cygwin=true"
|
||||
|
|
@ -405,7 +405,7 @@ run() {
|
|||
exit_code=$?
|
||||
|
||||
# Clean up the terminal from cygwin hacks.
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then #"
|
||||
stty icanon echo > /dev/null 2>&1
|
||||
fi
|
||||
exit $exit_code
|
||||
|
|
@ -421,41 +421,41 @@ usage() {
|
|||
cat <<EOM
|
||||
Usage: `basename "$0"` [options]
|
||||
|
||||
-h | -help print this message
|
||||
-v | -verbose this runner is chattier
|
||||
-d | -debug set sbt log level to debug
|
||||
-no-colors disable ANSI color codes
|
||||
-sbt-create start sbt even if current directory contains no sbt project
|
||||
-sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
|
||||
-sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
|
||||
-ivy <path> path to local Ivy repository (default: ~/.ivy2)
|
||||
-mem <integer> set memory options (default: $sbt_default_mem, which is $(get_mem_opts))
|
||||
-no-share use all local caches; no sharing
|
||||
-no-global uses global caches, but does not use global ~/.sbt directory.
|
||||
-jvm-debug <port> Turn on JVM debugging, open at the given port.
|
||||
-batch Disable interactive mode
|
||||
-h | --help print this message
|
||||
-v | --verbose this runner is chattier
|
||||
-d | --debug set sbt log level to debug
|
||||
--no-colors disable ANSI color codes
|
||||
--sbt-create start sbt even if current directory contains no sbt project
|
||||
--sbt-dir <path> path to global settings/plugins directory (default: ~/.sbt)
|
||||
--sbt-boot <path> path to shared boot directory (default: ~/.sbt/boot in 0.11 series)
|
||||
--ivy <path> path to local Ivy repository (default: ~/.ivy2)
|
||||
--mem <integer> set memory options (default: $sbt_default_mem, which is $(get_mem_opts))
|
||||
--no-share use all local caches; no sharing
|
||||
--no-global uses global caches, but does not use global ~/.sbt directory.
|
||||
--jvm-debug <port> Turn on JVM debugging, open at the given port.
|
||||
--batch Disable interactive mode
|
||||
|
||||
# sbt version (default: from project/build.properties if present, else latest release)
|
||||
-sbt-version <version> use the specified version of sbt
|
||||
-sbt-jar <path> use the specified jar as the sbt launcher
|
||||
-sbt-rc use an RC version of sbt
|
||||
-sbt-snapshot use a snapshot version of sbt
|
||||
--sbt-version <version> use the specified version of sbt
|
||||
--sbt-jar <path> use the specified jar as the sbt launcher
|
||||
--sbt-rc use an RC version of sbt
|
||||
--sbt-snapshot use a snapshot version of sbt
|
||||
|
||||
# java version (default: java from PATH, currently $(java -version 2>&1 | grep version))
|
||||
-java-home <path> alternate JAVA_HOME
|
||||
--java-home <path> alternate JAVA_HOME
|
||||
|
||||
# jvm options and output control
|
||||
JAVA_OPTS environment variable, if unset uses "$default_java_opts"
|
||||
.jvmopts if this file exists in the current directory, its contents
|
||||
are appended to JAVA_OPTS
|
||||
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
|
||||
.sbtopts if this file exists in the current directory, its contents
|
||||
are prepended to the runner args
|
||||
/etc/sbt/sbtopts if this file exists, it is prepended to the runner args
|
||||
-Dkey=val pass -Dkey=val directly to the java runtime
|
||||
-J-X pass option -X directly to the java runtime
|
||||
(-J is stripped)
|
||||
-S-X add -X to sbt's scalacOptions (-S is stripped)
|
||||
JAVA_OPTS environment variable, if unset uses "$default_java_opts"
|
||||
.jvmopts if this file exists in the current directory, its contents
|
||||
are appended to JAVA_OPTS
|
||||
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
|
||||
.sbtopts if this file exists in the current directory, its contents
|
||||
are prepended to the runner args
|
||||
/etc/sbt/sbtopts if this file exists, it is prepended to the runner args
|
||||
-Dkey=val pass -Dkey=val directly to the java runtime
|
||||
-J-X pass option -X directly to the java runtime
|
||||
(-J is stripped)
|
||||
-S-X add -X to sbt's scalacOptions (-S is stripped)
|
||||
|
||||
In the case of duplicated or conflicting options, the order above
|
||||
shows precedence: JAVA_OPTS lowest, command line options highest.
|
||||
|
|
@ -467,19 +467,19 @@ EOM
|
|||
process_my_args () {
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-no-colors) addJava "-Dsbt.log.noformat=true" && shift ;;
|
||||
-no-share) addJava "$noshare_opts" && shift ;;
|
||||
-no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;;
|
||||
-sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
|
||||
-sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;;
|
||||
-debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
|
||||
-batch) exec </dev/null && shift ;;
|
||||
-no-colors|--no-colors) addJava "-Dsbt.log.noformat=true" && shift ;;
|
||||
-no-share|--no-share) addJava "$noshare_opts" && shift ;;
|
||||
-no-global|--no-global) addJava "-Dsbt.global.base=$(pwd)/project/.sbtboot" && shift ;;
|
||||
-sbt-boot|--sbt-boot) require_arg path "$1" "$2" && addJava "-Dsbt.boot.directory=$2" && shift 2 ;;
|
||||
-sbt-dir|--sbt-dir) require_arg path "$1" "$2" && addJava "-Dsbt.global.base=$2" && shift 2 ;;
|
||||
-debug-inc|--debug-inc) addJava "-Dxsbt.inc.debug=true" && shift ;;
|
||||
-batch|--batch) exec </dev/null && shift ;; #>
|
||||
|
||||
-sbt-create) sbt_create=true && shift ;;
|
||||
-sbt-create|--sbt-create) sbt_create=true && shift ;;
|
||||
|
||||
new) sbt_new=true && addResidual "$1" && shift ;;
|
||||
new) sbt_new=true && addResidual "$1" && shift ;;
|
||||
|
||||
*) addResidual "$1" && shift ;;
|
||||
*) addResidual "$1" && shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -175,27 +175,27 @@ jdk_version() {
|
|||
process_args () {
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-h|-help) usage; exit 1 ;;
|
||||
-v|-verbose) verbose=1 && shift ;;
|
||||
-d|-debug) debug=1 && addSbt "-debug" && shift ;;
|
||||
-h|-help|--help) usage; exit 1 ;;
|
||||
-v|-verbose|--verbose) verbose=1 && shift ;;
|
||||
-d|-debug|--debug) debug=1 && addSbt "-debug" && shift ;;
|
||||
|
||||
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
|
||||
-mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;;
|
||||
-jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
|
||||
-batch) exec </dev/null && shift ;;
|
||||
-ivy|--ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;
|
||||
-mem|--mem) require_arg integer "$1" "$2" && sbt_mem="$2" && shift 2 ;;
|
||||
-jvm-debug|--jvm-debug) require_arg port "$1" "$2" && addDebugger $2 && shift 2 ;;
|
||||
-batch|--batch) exec </dev/null && shift ;;
|
||||
|
||||
-sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;;
|
||||
-sbt-version) require_arg version "$1" "$2" && sbt_version="$2" && shift 2 ;;
|
||||
-java-home) require_arg path "$1" "$2" &&
|
||||
java_cmd="$2/bin/java" &&
|
||||
export JAVA_HOME="$2" &&
|
||||
export JDK_HOME="$2" &&
|
||||
export PATH="$2/bin:$PATH" &&
|
||||
shift 2 ;;
|
||||
-sbt-jar|--sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;;
|
||||
-sbt-version|--sbt-version) require_arg version "$1" "$2" && sbt_version="$2" && shift 2 ;;
|
||||
-java-home|--java-home) require_arg path "$1" "$2" &&
|
||||
java_cmd="$2/bin/java" &&
|
||||
export JAVA_HOME="$2" &&
|
||||
export JDK_HOME="$2" &&
|
||||
export PATH="$2/bin:$PATH" &&
|
||||
shift 2 ;;
|
||||
|
||||
"-D*") addJava "$1" && shift ;;
|
||||
-J*) addJava "${1:2}" && shift ;;
|
||||
*) addResidual "$1" && shift ;;
|
||||
"-D*") addJava "$1" && shift ;;
|
||||
-J*) addJava "${1:2}" && shift ;;
|
||||
*) addResidual "$1" && shift ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,10 @@ set INIT_SBT_VERSION=_TO_BE_REPLACED
|
|||
:args_loop
|
||||
if "%~1" == "" goto args_end
|
||||
|
||||
if "%~1" == "-jvm-debug" (
|
||||
set JVM_DEBUG=true
|
||||
if "%~1" == "-jvm-debug" set set JVM_DEBUG=true
|
||||
if "%~1" == "--jvm-debug" set set JVM_DEBUG=true
|
||||
|
||||
if "%JVM_DEBUG%" == "true" (
|
||||
set /a JVM_DEBUG_PORT=5005 2>nul >nul
|
||||
) else if "!JVM_DEBUG!" == "true" (
|
||||
set /a JVM_DEBUG_PORT=%1 2>nul >nul
|
||||
|
|
|
|||
Loading…
Reference in New Issue