This commit is contained in:
@ -7,6 +7,7 @@ import com.github.ajalt.clikt.parameters.arguments.argument
|
||||
import com.github.ajalt.clikt.parameters.arguments.help
|
||||
import com.github.ajalt.clikt.parameters.arguments.multiple
|
||||
import com.github.ajalt.clikt.parameters.options.default
|
||||
import com.github.ajalt.clikt.parameters.options.defaultLazy
|
||||
import com.github.ajalt.clikt.parameters.options.flag
|
||||
import com.github.ajalt.clikt.parameters.options.help
|
||||
import com.github.ajalt.clikt.parameters.options.option
|
||||
@ -51,15 +52,13 @@ class DevCommand : CliktCommand("dev") {
|
||||
override val treatUnknownOptionsAsArgs = true
|
||||
|
||||
val server by argument().help("Server Template")
|
||||
val port by option("--port").long().default(
|
||||
if (System.getProperty("os.name").lowercase() == "windows"
|
||||
) 2050 else (UnixSystem().uid + 1010)
|
||||
).help("Port for Server")
|
||||
val port by option("--port").long().defaultLazy { UnixSystem().uid + 1010 }.help("Port for Server")
|
||||
val world by option("--world", "-w").path(canBeFile = false).help("User World")
|
||||
val plugins by option("--plugins", "-p").path(true, canBeFile = false).help("Plugin Dir")
|
||||
val profile by option().flag().help("Add Profiling Arguments")
|
||||
val forceUpgrade by option().flag().help("Force Upgrade")
|
||||
val jar by option().file(true, canBeDir = false).help("Jar File")
|
||||
val jvm by option().file(true, canBeDir = false).help("Java Executable")
|
||||
val jvmArgs by argument().multiple()
|
||||
|
||||
override val printHelpOnEmptyArgs = true
|
||||
@ -110,8 +109,7 @@ class DevCommand : CliktCommand("dev") {
|
||||
|
||||
try {
|
||||
devFile.delete()
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
} catch (_: Exception) { /* ignored */ }
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,8 +162,8 @@ class DevCommand : CliktCommand("dev") {
|
||||
}
|
||||
|
||||
fun runServer(args: List<String>, jvmArgs: List<String>, cmd: List<String>, serverDir: File) {
|
||||
val command = arrayOf(
|
||||
if (isJava8(server)) "/usr/lib/jvm/openj9-8/bin/java" else "java",
|
||||
val process = ProcessBuilder(
|
||||
jvm?.absolutePath ?: if (isJava8(server)) "/usr/lib/jvm/openj9-8/bin/java" else "java",
|
||||
*jvmArgs.toTypedArray(),
|
||||
*args.toTypedArray(),
|
||||
*jvmDefaultParams,
|
||||
@ -174,10 +172,6 @@ class DevCommand : CliktCommand("dev") {
|
||||
"-Xshareclasses:nonfatal,name=$server",
|
||||
"-jar",
|
||||
*cmd.toTypedArray()
|
||||
)
|
||||
echo(command.joinToString(" "))
|
||||
val process = ProcessBuilder(
|
||||
*command
|
||||
).directory(serverDir).inheritIO().start()
|
||||
process.waitFor()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user