Merge pull request #276 from exoego/fix-4833-print-sbtVersion

Add -V|-version to print sbtVersion.
This commit is contained in:
eugene yokota 2019-07-19 23:09:36 -04:00 committed by GitHub
commit 10693a800a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 10 deletions

View File

@ -10,6 +10,7 @@ Usage: sbt [options]
-h | -help print this message -h | -help print this message
-v | -verbose this runner is chattier -v | -verbose this runner is chattier
-V | -version print the version of mothership sbt
-d | -debug set sbt log level to debug -d | -debug set sbt log level to debug
-no-colors disable ANSI color codes -no-colors disable ANSI color codes
-sbt-create start sbt even if current directory contains no sbt project -sbt-create start sbt even if current directory contains no sbt project

View File

@ -79,4 +79,14 @@ object SbtRunnerTest extends SimpleTestSuite with PowerAssertions {
() ()
} }
test("sbt -V|-version should print sbtVersion") {
val out = sbtProcessWithOpts("-version", "", "").!!.trim
val expectedVersion = "^sbt version in this project: \\d\\.\\d+\\.\\d+\\S*$"
assert(out.matches(expectedVersion))
val out2 = sbtProcessWithOpts("-V", "", "").!!.trim
assert(out2.matches(expectedVersion))
()
}
} }

View File

@ -20,6 +20,8 @@ The current directory is assumed to be the project.
Show help options. Show help options.
.IP "-v, -verbose" .IP "-v, -verbose"
turn up the noise turn up the noise
.IP "-V, -version"
print the version of mothership sbt
.IP "-d, -debug" .IP "-d, -debug"
set sbt log level to debug set sbt log level to debug
.IP -no-colors .IP -no-colors

View File

@ -6,6 +6,7 @@ declare -a java_args
declare -a scalac_args declare -a scalac_args
declare -a sbt_commands declare -a sbt_commands
declare -a sbt_options declare -a sbt_options
declare -a print_sbt_version
declare java_cmd=java declare java_cmd=java
declare java_version declare java_version
declare init_sbt_version=_to_be_replaced declare init_sbt_version=_to_be_replaced
@ -375,6 +376,10 @@ run() {
addJava "-Dsbt.cygwin=true" addJava "-Dsbt.cygwin=true"
fi fi
if [[ $print_sbt_version ]]; then
# print sbtVersion
execRunner "$java_cmd" -jar "$sbt_jar" "sbtVersion" | tail -1 | sed -e 's/\[info\]/sbt version in this project:/g'
else
# run sbt # run sbt
execRunner "$java_cmd" \ execRunner "$java_cmd" \
$(get_gc_opts) \ $(get_gc_opts) \
@ -383,6 +388,7 @@ run() {
-jar "$sbt_jar" \ -jar "$sbt_jar" \
"${sbt_commands[@]}" \ "${sbt_commands[@]}" \
"${residual_args[@]}" "${residual_args[@]}"
fi
exit_code=$? exit_code=$?
@ -405,6 +411,7 @@ Usage: `basename "$0"` [options]
-h | --help print this message -h | --help print this message
-v | --verbose this runner is chattier -v | --verbose this runner is chattier
-V | --version print the version of mothership sbt
-d | --debug set sbt log level to debug -d | --debug set sbt log level to debug
--no-colors disable ANSI color codes --no-colors disable ANSI color codes
--color=auto|always|true|false|never --color=auto|always|true|false|never
@ -512,6 +519,7 @@ process_args () {
case "$1" in case "$1" in
-h|-help) usage; exit 1 ;; -h|-help) usage; exit 1 ;;
-v|-verbose) verbose=1 && shift ;; -v|-verbose) verbose=1 && shift ;;
-V|-version) print_sbt_version=1 && shift ;;
-d|-debug) debug=1 && addSbt "-debug" && shift ;; -d|-debug) debug=1 && addSbt "-debug" && shift ;;
-ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;; -ivy) require_arg path "$1" "$2" && addJava "-Dsbt.ivy.home=$2" && shift 2 ;;