Skip to content

Commit

Permalink
refactor: Use a newline for annotation properties
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Nov 26, 2023
1 parent 36c6a6a commit 5e63e0a
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 27 deletions.
19 changes: 14 additions & 5 deletions src/main/kotlin/app/revanced/cli/command/ListPatchesCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@ import java.io.File
import java.util.logging.Logger


@Command(name = "list-patches", description = ["List patches from supplied patch bundles."])
@Command(
name = "list-patches",
description = ["List patches from supplied patch bundles."]
)
internal object ListPatchesCommand : Runnable {
private val logger = Logger.getLogger(ListPatchesCommand::class.java.name)

@Parameters(
description = ["Paths to patch bundles."], arity = "1..*"
description = ["Paths to patch bundles."],
arity = "1..*"
)
private lateinit var patchBundles: Array<File>

@Option(
names = ["-d", "--with-descriptions"], description = ["List their descriptions."], showDefaultValue = ALWAYS
names = ["-d", "--with-descriptions"],
description = ["List their descriptions."],
showDefaultValue = ALWAYS
)
private var withDescriptions: Boolean = true

Expand All @@ -38,7 +44,9 @@ internal object ListPatchesCommand : Runnable {
private var withVersions: Boolean = false

@Option(
names = ["-o", "--with-options"], description = ["List the options of the patches."], showDefaultValue = ALWAYS
names = ["-o", "--with-options"],
description = ["List the options of the patches."],
showDefaultValue = ALWAYS
)
private var withOptions: Boolean = false

Expand All @@ -57,7 +65,8 @@ internal object ListPatchesCommand : Runnable {
private var withIndex: Boolean = true

@Option(
names = ["-f", "--filter-package-name"], description = ["Filter patches by package name."]
names = ["-f", "--filter-package-name"],
description = ["Filter patches by package name."]
)
private var packageName: String? = null

Expand Down
11 changes: 8 additions & 3 deletions src/main/kotlin/app/revanced/cli/command/OptionsCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,22 @@ internal object OptionsCommand : Runnable {
private val logger = Logger.getLogger(OptionsCommand::class.java.name)

@CommandLine.Parameters(
description = ["Paths to patch bundles."], arity = "1..*"
description = ["Paths to patch bundles."],
arity = "1..*"
)
private lateinit var patchBundles: Array<File>

@CommandLine.Option(
names = ["-p", "--path"], description = ["Path to patch options JSON file."], showDefaultValue = ALWAYS
names = ["-p", "--path"],
description = ["Path to patch options JSON file."],
showDefaultValue = ALWAYS
)
private var filePath: File = File("options.json")

@CommandLine.Option(
names = ["-o", "--overwrite"], description = ["Overwrite existing options file."], showDefaultValue = ALWAYS
names = ["-o", "--overwrite"],
description = ["Overwrite existing options file."],
showDefaultValue = ALWAYS
)
private var overwrite: Boolean = false

Expand Down
47 changes: 33 additions & 14 deletions src/main/kotlin/app/revanced/cli/command/PatchCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import java.util.logging.Logger


@CommandLine.Command(
name = "patch", description = ["Patch an APK file."]
name = "patch",
description = ["Patch an APK file."]
)
internal object PatchCommand : Runnable {
private val logger = Logger.getLogger(PatchCommand::class.java.name)
Expand All @@ -35,7 +36,8 @@ internal object PatchCommand : Runnable {
private var patchBundles = emptyList<File>()

@CommandLine.Option(
names = ["-i", "--include"], description = ["List of patches to include."]
names = ["-i", "--include"],
description = ["List of patches to include."]
)
private var includedPatches = hashSetOf<String>()

Expand All @@ -46,7 +48,8 @@ internal object PatchCommand : Runnable {
private var includedPatchesByIndex = arrayOf<Int>()

@CommandLine.Option(
names = ["-e", "--exclude"], description = ["List of patches to exclude."]
names = ["-e", "--exclude"],
description = ["List of patches to exclude."]
)
private var excludedPatches = hashSetOf<String>()

Expand All @@ -57,7 +60,9 @@ internal object PatchCommand : Runnable {
private var excludedPatchesByIndex = arrayOf<Int>()

@CommandLine.Option(
names = ["--options"], description = ["Path to patch options JSON file."], showDefaultValue = ALWAYS
names = ["--options"],
description = ["Path to patch options JSON file."],
showDefaultValue = ALWAYS
)
private var optionsFile: File = File("options.json")

Expand All @@ -76,22 +81,29 @@ internal object PatchCommand : Runnable {
private var force: Boolean = false

@CommandLine.Option(
names = ["-o", "--out"], description = ["Path to save the patched APK file to."], required = true
names = ["-o", "--out"],
description = ["Path to save the patched APK file to."],
required = true
)
private lateinit var outputFilePath: File

@CommandLine.Option(
names = ["-d", "--device-serial"], description = ["ADB device serial to install to."], showDefaultValue = ALWAYS
names = ["-d", "--device-serial"],
description = ["ADB device serial to install to."],
showDefaultValue = ALWAYS
)
private var deviceSerial: String? = null

@CommandLine.Option(
names = ["--mount"], description = ["Install by mounting the patched APK file."], showDefaultValue = ALWAYS
names = ["--mount"],
description = ["Install by mounting the patched APK file."],
showDefaultValue = ALWAYS
)
private var mount: Boolean = false

@CommandLine.Option(
names = ["--keystore"], description = ["Path to the keystore to sign the patched APK file with."],
names = ["--keystore"],
description = ["Path to the keystore to sign the patched APK file with."],
)
private var keystoreFilePath: File? = null

Expand All @@ -103,7 +115,8 @@ internal object PatchCommand : Runnable {
private var keyStorePassword: String? = null // Empty password by default

@CommandLine.Option(
names = ["--alias"], description = ["The alias of the key from the keystore to sign the patched APK file with."],
names = ["--alias"],
description = ["The alias of the key from the keystore to sign the patched APK file with."],
showDefaultValue = ALWAYS
)
private var alias = "ReVanced Key"
Expand All @@ -115,7 +128,8 @@ internal object PatchCommand : Runnable {
private var password = "" // Empty password by default

@CommandLine.Option(
names = ["--signer"], description = ["The name of the signer to sign the patched APK file with."],
names = ["--signer"],
description = ["The name of the signer to sign the patched APK file with."],
showDefaultValue = ALWAYS
)
private var signer = "ReVanced"
Expand Down Expand Up @@ -144,7 +158,8 @@ internal object PatchCommand : Runnable {
private var warn: Boolean = false

@CommandLine.Parameters(
description = ["APK file to be patched."], arity = "1..1"
description = ["APK file to be patched."],
arity = "1..1"
)
@Suppress("unused")
private fun setApk(apk: File) {
Expand All @@ -156,7 +171,8 @@ internal object PatchCommand : Runnable {
}

@CommandLine.Option(
names = ["-m", "--merge"], description = ["One or more DEX files or containers to merge into the APK."]
names = ["-m", "--merge"],
description = ["One or more DEX files or containers to merge into the APK."]
)
@Suppress("unused")
private fun setIntegrations(integrations: Array<File>) {
Expand All @@ -167,7 +183,9 @@ internal object PatchCommand : Runnable {
}

@CommandLine.Option(
names = ["-b", "--patch-bundle"], description = ["One or more bundles of patches."], required = true
names = ["-b", "--patch-bundle"],
description = ["One or more bundles of patches."],
required = true
)
@Suppress("unused")
private fun setPatchBundles(patchBundles: Array<File>) {
Expand All @@ -178,7 +196,8 @@ internal object PatchCommand : Runnable {
}

@CommandLine.Option(
names = ["--custom-aapt2-binary"], description = ["Path to a custom AAPT binary to compile resources with."]
names = ["--custom-aapt2-binary"],
description = ["Path to a custom AAPT binary to compile resources with."]
)
@Suppress("unused")
private fun setAaptBinaryPath(aaptBinaryPath: File) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ import java.util.logging.Logger


@Command(
name = "install", description = ["Install an APK file to devices with the supplied ADB device serials"]
name = "install",
description = ["Install an APK file to devices with the supplied ADB device serials"]
)
internal object InstallCommand : Runnable {
private val logger = Logger.getLogger(InstallCommand::class.java.name)

@Parameters(
description = ["ADB device serials"], arity = "1..*"
description = ["ADB device serials"],
arity = "1..*"
)
private lateinit var deviceSerials: Array<String>

@Option(
names = ["-a", "--apk"], description = ["APK file to be installed"], required = true
names = ["-a", "--apk"],
description = ["APK file to be installed"],
required = true
)
private lateinit var apk: File

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ import java.util.logging.Logger
internal object UninstallCommand : Runnable {
private val logger = Logger.getLogger(UninstallCommand::class.java.name)

@Parameters(description = ["ADB device serials"], arity = "1..*")
@Parameters(
description = ["ADB device serials"],
arity = "1..*"
)
private lateinit var deviceSerials: Array<String>

@Option(names = ["-p", "--package-name"], description = ["Package name of the app to uninstall"], required = true)
@Option(
names = ["-p", "--package-name"],
description = ["Package name of the app to uninstall"],
required = true
)
private lateinit var packageName: String

@Option(
Expand Down

0 comments on commit 5e63e0a

Please sign in to comment.