diff --git a/src/main/kotlin/app/revanced/cli/command/MainCommand.kt b/src/main/kotlin/app/revanced/cli/command/MainCommand.kt index 55614e3..40094df 100644 --- a/src/main/kotlin/app/revanced/cli/command/MainCommand.kt +++ b/src/main/kotlin/app/revanced/cli/command/MainCommand.kt @@ -23,10 +23,10 @@ internal object MainCommand : Runnable { var patchBundles = arrayOf() @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( diff --git a/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt b/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt index 633fe34..5d44415 100644 --- a/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/cli/patcher/Patcher.kt @@ -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() diff --git a/src/main/kotlin/app/revanced/cli/signing/Signing.kt b/src/main/kotlin/app/revanced/cli/signing/Signing.kt index 6579042..c0ed893 100644 --- a/src/main/kotlin/app/revanced/cli/signing/Signing.kt +++ b/src/main/kotlin/app/revanced/cli/signing/Signing.kt @@ -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") diff --git a/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt b/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt index 41ef72c..e322a20 100644 --- a/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/utils/patcher/Patcher.kt @@ -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>>() 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) }