Skip to content

Commit

Permalink
Update diffuse.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski committed Sep 22, 2024
1 parent 7205f0e commit 85891a6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions diffuse/src/main/kotlin/com/jakewharton/diffuse/diffuse.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
package com.jakewharton.diffuse

import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.Context
import com.github.ajalt.clikt.core.NoOpCliktCommand
import com.github.ajalt.clikt.core.ParameterHolder
import com.github.ajalt.clikt.core.main
import com.github.ajalt.clikt.core.subcommands
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.groups.OptionGroup
Expand Down Expand Up @@ -142,12 +144,14 @@ private class InfoCommand(
inputFs: FileSystem,
outputFs: FileSystem,
output: PrintStream,
) : CliktCommand(name = "info", help = "Display info about a binary.") {
) : CliktCommand(name = "info") {
private val type by binaryType()
private val outputOptions by OutputOptions(outputFs, output)
private val file by argument("FILE", help = "Input file.")
.path(mustExist = true, canBeDir = false, mustBeReadable = true, fileSystem = inputFs)

override fun help(context: Context) = "Display info about a binary."

override fun run() {
val info = when (type) {
BinaryType.Apk -> ApkInfo(file.asInput().toApk())
Expand All @@ -164,7 +168,7 @@ private class DiffCommand(
inputFs: FileSystem,
outputFs: FileSystem,
output: PrintStream,
) : CliktCommand(name = "diff", help = "Display changes between two binaries.") {
) : CliktCommand(name = "diff") {
private val inputOptions by object : OptionGroup("Input options") {
private val type by binaryType()

Expand All @@ -188,6 +192,8 @@ private class DiffCommand(
private val new by argument("NEW", help = "New input file.")
.path(mustExist = true, canBeDir = false, mustBeReadable = true, fileSystem = inputFs)

override fun help(context: Context) = "Display changes between two binaries."

override fun run() {
val diff = inputOptions.parse(old.asInput(), new.asInput())
outputOptions.write(diff)
Expand All @@ -197,7 +203,7 @@ private class DiffCommand(
private class MembersCommand(
inputFs: FileSystem,
private val stdout: PrintStream,
) : CliktCommand(name = "members", help = "List methods or fields of a binary.") {
) : CliktCommand(name = "members") {
private val binary by argument("FILE", help = "Input file.")
.path(mustExist = true, canBeDir = false, mustBeReadable = true, fileSystem = inputFs)

Expand Down Expand Up @@ -237,6 +243,8 @@ private class MembersCommand(
Referenced,
}

override fun help(context: Context) = "List methods or fields of a binary."

override fun run() {
val input = binary.asInput()

Expand Down

0 comments on commit 85891a6

Please sign in to comment.