This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
forked from inotia00/revanced-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use separate command to uninstall
- Loading branch information
Showing
4 changed files
with
74 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/kotlin/app/revanced/cli/command/UninstallCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package app.revanced.cli.command | ||
|
||
import app.revanced.utils.adb.AdbManager | ||
import picocli.CommandLine | ||
import picocli.CommandLine.Help.Visibility.ALWAYS | ||
|
||
|
||
@CommandLine.Command( | ||
name = "uninstall", | ||
description = ["Uninstall a patched package from the devices with the supplied ADB device serials"] | ||
) | ||
class UninstallCommand : Runnable { | ||
@CommandLine.Parameters( | ||
description = ["ADB device serials"], | ||
arity = "1..*" | ||
) | ||
lateinit var deviceSerials: Array<String> | ||
|
||
@CommandLine.Option( | ||
names = ["-p", "--package-name"], | ||
description = ["Package name to uninstall"], | ||
required = true | ||
) | ||
lateinit var packageName: String | ||
|
||
@CommandLine.Option( | ||
names = ["-u", "--unmount"], | ||
description = ["Uninstall by unmounting the patched package"], | ||
showDefaultValue = ALWAYS | ||
) | ||
var unmount: Boolean = false | ||
|
||
override fun run() = try { | ||
deviceSerials.forEach {deviceSerial -> | ||
if (unmount) { | ||
AdbManager.RootAdbManager(deviceSerial, MainCommand.logger) | ||
} else { | ||
AdbManager.UserAdbManager(deviceSerial, MainCommand.logger) | ||
}.uninstall(packageName) | ||
} | ||
} catch (e: AdbManager.DeviceNotFoundException) { | ||
MainCommand.logger.error(e.toString()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters