forked from openrs2/openrs2
parent
ba75306169
commit
3e60a82ca1
@ -0,0 +1,32 @@ |
||||
plugins { |
||||
`maven-publish` |
||||
application |
||||
kotlin("jvm") |
||||
} |
||||
|
||||
application { |
||||
mainClass.set("org.openrs2.cache.cli.CacheCommandKt") |
||||
} |
||||
|
||||
dependencies { |
||||
api(libs.clikt) |
||||
|
||||
implementation(projects.cache) |
||||
implementation(projects.inject) |
||||
} |
||||
|
||||
publishing { |
||||
publications.create<MavenPublication>("maven") { |
||||
from(components["java"]) |
||||
|
||||
pom { |
||||
packaging = "jar" |
||||
name.set("OpenRS2 Cache CLI") |
||||
description.set( |
||||
""" |
||||
Tools for working with RuneScape caches. |
||||
""".trimIndent() |
||||
) |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
package org.openrs2.cache.cli |
||||
|
||||
import com.github.ajalt.clikt.core.NoOpCliktCommand |
||||
import com.github.ajalt.clikt.core.subcommands |
||||
|
||||
public fun main(args: Array<String>): Unit = CacheCommand().main(args) |
||||
|
||||
public class CacheCommand : NoOpCliktCommand(name = "cache") { |
||||
init { |
||||
subcommands( |
||||
RuneLiteUnpackCommand() |
||||
) |
||||
} |
||||
} |
@ -0,0 +1,27 @@ |
||||
package org.openrs2.cache.cli |
||||
|
||||
import com.github.ajalt.clikt.core.CliktCommand |
||||
import com.github.ajalt.clikt.parameters.arguments.argument |
||||
import com.github.ajalt.clikt.parameters.types.path |
||||
import com.google.inject.Guice |
||||
import io.netty.buffer.ByteBufAllocator |
||||
import org.openrs2.cache.CacheModule |
||||
import org.openrs2.cache.RuneLiteStore |
||||
import org.openrs2.cache.Store |
||||
import org.openrs2.inject.CloseableInjector |
||||
|
||||
public class RuneLiteUnpackCommand : CliktCommand(name = "unpack-runelite") { |
||||
private val input by argument().path(mustExist = true, canBeFile = false, mustBeReadable = true) |
||||
private val output by argument().path(canBeFile = false, mustBeReadable = true, mustBeWritable = true) |
||||
|
||||
override fun run() { |
||||
CloseableInjector(Guice.createInjector(CacheModule)).use { injector -> |
||||
val alloc = injector.getInstance(ByteBufAllocator::class.java) |
||||
val runeLiteStore = injector.getInstance(RuneLiteStore::class.java) |
||||
|
||||
Store.open(output, alloc).use { store -> |
||||
runeLiteStore.unpack(input, store) |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue