Add cli command arguments
This commit is contained in:
parent
67ac2b272e
commit
19324c6247
@ -23,6 +23,7 @@ val log4jVersion: String by project
|
|||||||
val guavaVersion: String by project
|
val guavaVersion: String by project
|
||||||
val junitVersion: String by project
|
val junitVersion: String by project
|
||||||
val sqliteVersion: String by project
|
val sqliteVersion: String by project
|
||||||
|
val picocliVersion: String by project
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
@ -91,6 +92,8 @@ dependencies {
|
|||||||
implementation("com.github.ben-manes.caffeine:caffeine:$caffeineVersion")
|
implementation("com.github.ben-manes.caffeine:caffeine:$caffeineVersion")
|
||||||
implementation(project(":luna"))
|
implementation(project(":luna"))
|
||||||
|
|
||||||
|
implementation("info.picocli:picocli:$picocliVersion")
|
||||||
|
|
||||||
implementation("org.xerial:sqlite-jdbc:$sqliteVersion")
|
implementation("org.xerial:sqlite-jdbc:$sqliteVersion")
|
||||||
|
|
||||||
implementation("io.netty:netty-transport:$nettyVersion")
|
implementation("io.netty:netty-transport:$nettyVersion")
|
||||||
|
@ -17,3 +17,5 @@ log4jVersion=2.17.1
|
|||||||
guavaVersion=33.0.0-jre
|
guavaVersion=33.0.0-jre
|
||||||
junitVersion=5.8.2
|
junitVersion=5.8.2
|
||||||
sqliteVersion=3.45.3.0
|
sqliteVersion=3.45.3.0
|
||||||
|
|
||||||
|
picocliVersion=4.7.6
|
||||||
|
@ -2,30 +2,73 @@ package ru.dbotthepony.kstarbound
|
|||||||
|
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import org.lwjgl.Version
|
import org.lwjgl.Version
|
||||||
|
import picocli.CommandLine
|
||||||
|
import picocli.CommandLine.Command
|
||||||
|
import picocli.CommandLine.Option
|
||||||
|
import picocli.CommandLine.Parameters
|
||||||
import ru.dbotthepony.kstarbound.client.StarboundClient
|
import ru.dbotthepony.kstarbound.client.StarboundClient
|
||||||
import ru.dbotthepony.kstarbound.server.IntegratedStarboundServer
|
import ru.dbotthepony.kstarbound.server.IntegratedStarboundServer
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
|
import java.util.concurrent.Callable
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
private val LOGGER = LogManager.getLogger()
|
private val LOGGER = LogManager.getLogger()
|
||||||
|
|
||||||
fun main() {
|
@Command(
|
||||||
Starbound.addArchive(File("J:\\Steam\\steamapps\\common\\Starbound\\assets\\packed.pak"))
|
name = "client",
|
||||||
|
mixinStandardHelpOptions = true,
|
||||||
|
description = ["Launches game client"]
|
||||||
|
)
|
||||||
|
class StartClientCommand : Callable<Int> {
|
||||||
|
@Option(names = ["-d", "--data"], description = ["Game folder where Starbound is installed.", "Defaults to working directory."])
|
||||||
|
var dataFolder: String = "./"
|
||||||
|
|
||||||
/*for (f in File("J:\\Steam\\steamapps\\workshop\\content\\211820").listFiles()!!) {
|
@Option(names = ["-s", "--storage"], description = ["Location where to store game files.", "Defaults to game's 'storage' subfolder"])
|
||||||
for (f2 in f.listFiles()!!) {
|
var storageFolder: String? = null
|
||||||
if (f2.isFile) {
|
|
||||||
Starbound.addArchive(f2)
|
override fun call(): Int {
|
||||||
}
|
val data = File(dataFolder)
|
||||||
|
|
||||||
|
if (!data.exists()) {
|
||||||
|
LOGGER.fatal("No such file ${data.absolutePath}")
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
|
||||||
LOGGER.info("Running LWJGL ${Version.getVersion()}")
|
val file = File("${dataFolder}/assets/packed.pak")
|
||||||
|
|
||||||
val client = StarboundClient()
|
if (!file.exists()) {
|
||||||
|
LOGGER.fatal("No such file ${file.absolutePath}")
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
Starbound.initializeGame().thenApply {
|
Starbound.addArchive(file)
|
||||||
val server = IntegratedStarboundServer(client, File("./storage"))
|
|
||||||
server.channels.createChannel(InetSocketAddress(21060))
|
/*for (f in File("J:\\Steam\\steamapps\\workshop\\content\\211820").listFiles()!!) {
|
||||||
}.exceptionally { LOGGER.error("what", it); null }
|
for (f2 in f.listFiles()!!) {
|
||||||
|
if (f2.isFile) {
|
||||||
|
Starbound.addArchive(f2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
LOGGER.info("Running LWJGL ${Version.getVersion()}")
|
||||||
|
|
||||||
|
val client = StarboundClient()
|
||||||
|
|
||||||
|
Starbound.initializeGame().thenApply {
|
||||||
|
val server = IntegratedStarboundServer(client, if (storageFolder == null) File(data, "storage") else File(storageFolder!!))
|
||||||
|
server.channels.createChannel(InetSocketAddress(21060))
|
||||||
|
}.exceptionally { LOGGER.error("what", it); null }
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(vararg args: String) {
|
||||||
|
val result = CommandLine(StartClientCommand()).execute(*args)
|
||||||
|
|
||||||
|
if (result != 0) {
|
||||||
|
exitProcess(result)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user