mirror of
https://github.com/revanced/revanced-cli.git
synced 2024-12-04 17:32:53 +01:00
refactor: replace try catch
block with null check
This commit is contained in:
parent
c7d72c4d1c
commit
430de23856
@ -23,10 +23,10 @@ internal object MainCommand : Runnable {
|
||||
var patchBundles = arrayOf<String>()
|
||||
|
||||
@ArgGroup(exclusive = false)
|
||||
lateinit var lArgs: ListingArgs
|
||||
var lArgs: ListingArgs? = null
|
||||
|
||||
@ArgGroup(exclusive = false)
|
||||
lateinit var pArgs: PatchingArgs
|
||||
var pArgs: PatchingArgs? = null
|
||||
}
|
||||
|
||||
class ListingArgs {
|
||||
@ -79,17 +79,14 @@ internal object MainCommand : Runnable {
|
||||
}
|
||||
|
||||
override fun run() {
|
||||
try {
|
||||
if (args.lArgs.listOnly) {
|
||||
for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||
println("[available] ${patch.patchName}")
|
||||
}
|
||||
return
|
||||
if (args.lArgs?.listOnly == true) {
|
||||
for (patchBundlePath in args.patchBundles) for (patch in JarPatchBundle(patchBundlePath).loadPatches()) {
|
||||
println("[available] ${patch.patchName}")
|
||||
}
|
||||
} catch (_: UninitializedPropertyAccessException) {
|
||||
return
|
||||
}
|
||||
|
||||
val args = args.pArgs
|
||||
val args = args.pArgs?: return
|
||||
|
||||
val patcher = app.revanced.patcher.Patcher(
|
||||
PatcherOptions(
|
||||
|
@ -10,7 +10,7 @@ import java.nio.file.Files
|
||||
|
||||
internal object Patcher {
|
||||
internal fun start(patcher: app.revanced.patcher.Patcher, output: File) {
|
||||
val args = args.pArgs;
|
||||
val args = args.pArgs!!
|
||||
|
||||
// merge files like necessary integrations
|
||||
patcher.mergeFiles()
|
||||
|
@ -7,7 +7,7 @@ import java.io.File
|
||||
|
||||
object Signing {
|
||||
fun start(inputFile: File, outputFile: File, cn: String, password: String) {
|
||||
val cacheDirectory = File(args.pArgs.cacheDirectory)
|
||||
val cacheDirectory = File(args.pArgs!!.cacheDirectory)
|
||||
val alignedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_aligned.apk")
|
||||
val signedOutput = cacheDirectory.resolve("${outputFile.nameWithoutExtension}_signed.apk")
|
||||
|
||||
|
@ -16,7 +16,7 @@ fun Patcher.addPatchesFiltered(
|
||||
val packageName = this.data.packageMetadata.packageName
|
||||
val packageVersion = this.data.packageMetadata.packageVersion
|
||||
|
||||
MainCommand.args.patchBundles.forEach { bundle ->
|
||||
args.patchBundles.forEach { bundle ->
|
||||
val includedPatches = mutableListOf<Class<out Patch<Data>>>()
|
||||
JarPatchBundle(bundle).loadPatches().forEach patch@{ patch ->
|
||||
val compatiblePackages = patch.compatiblePackages
|
||||
@ -24,7 +24,7 @@ fun Patcher.addPatchesFiltered(
|
||||
|
||||
val prefix = "[skipped] $patchName"
|
||||
|
||||
val args = MainCommand.args.pArgs
|
||||
val args = MainCommand.args.pArgs!!
|
||||
|
||||
if (includeFilter) {
|
||||
if (!args.includedPatches.contains(patchName)) {
|
||||
@ -68,5 +68,5 @@ fun Patcher.applyPatchesVerbose() {
|
||||
}
|
||||
|
||||
fun Patcher.mergeFiles() {
|
||||
this.addFiles(MainCommand.args.pArgs.mergeFiles)
|
||||
this.addFiles(args.pArgs!!.mergeFiles)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user