Skip to content

Commit

Permalink
feat: Set patch options via CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Aug 3, 2024
1 parent 508b1c2 commit 2138376
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 129 deletions.
71 changes: 62 additions & 9 deletions docs/1_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ java -jar revanced-cli.jar -h
## 📃 List patches

```bash
java -jar revanced-cli.jar list-patches --with-descriptions --with-packages --with-versions --with-options --with-universal-patches revanced-patches.rvp
java -jar revanced-cli.jar list-patches --with-packages --with-versions --with-options revanced-patches.rvp
```

## 💉 Patch an app with the default list of patches
Expand All @@ -28,22 +28,36 @@ You can also use multiple patch bundles:
java -jar revanced-cli.jar patch -b revanced-patches.rvp -b another-patches.rvp input.apk
```

To manually include or exclude patches, use the options `-i` and `-e`.
Keep in mind the name of the patch must be an exact match.
You can also use the options `--ii` and `--ie` to include or exclude patches by their index
if two patches have the same name.
To know the indices of patches, use the option `--with-indices` when listing patches:
To manually use patches that are not used by default, use the option `-i`.
To not use patches that are used by default, use the option `-e`.
You can also disuse all patches by default by using the option `--exclusive` and then use `-i` to use specific patches.
Keep in mind the name of the patch must be an exact match. Here is an example:

```bash
java -jar revanced-cli.jar list-patches --with-indices revanced-patches.rvp
java -jar revanced-cli.jar patch -b revanced-patches.rvp --exclusive -i "Patch name" -i "Another patch name" input.apk
```

Then you can use the indices to include or exclude patches:
You can also use the options `--ii` and `--ie` to use or disuse patches by their index.
This is useful, if two patches happen to have the same name.
To know the indices of patches, use the command `list-patches`:

```bash
java -jar revanced-cli.jar list-patches revanced-patches.rvp
```

Then you can use the indices to use or disuse patches:

```bash
java -jar revanced-cli.jar patch -b revanced-patches.rvp --ii 123 --ie 456 input.apk
```

You can combine the option `-i`, `-e`, `--ii`, `--ie` and `--exclusive`. Here is an example:

```bash
java -jar revanced-cli.jar patch -b revanced-patches.rvp --exclusive -i "Patch name" --ii 123 input.apk
```


> [!TIP]
> You can use the option `-d` to automatically install the patched app after patching.
> Make sure ADB is working:
Expand All @@ -62,7 +76,46 @@ java -jar revanced-cli.jar patch -b revanced-patches.rvp --ii 123 --ie 456 input
> adb install input.apk
> ```
## 📦 Install an app manually
Patches can have options that you can set using the option `--set-options`.
To know the options of a patch, use the option `--with-options` when listing patches:
```bash
java -jar revanced-cli.jar list-patches --with-options revanced-patches.rvp
```
Each patch can have multiple options. You can set them using the option `--set-options`.
For example, to set the options for the patch with the name `Patch name`
with the key `key1` and `key2` to `value1` and `value2` respectively, use the following command:

```bash
java -jar revanced-cli.jar patch -b revanced-patches.rvp --set-options "Patch name" -Okey1=value1 -Okey2=value2 input.apk
```

If you want to set a value to `null`, you can omit the value:

```bash
java -jar revanced-cli.jar patch -b revanced-patches.rvp --set-options "Patch name" -Okey1 input.apk
```

> [!WARNING]
> The values of options are typed. If you set a value with the wrong type, the patching process will fail.
> The type of the option value can be seen when listing patches with the option `--with-options`.
>
> Example values:
>
> String: `string`
> Boolean: `true`, `false`
> Integer: `123`
> Double: `1.0`
> Float: `1.0f`
> Long: `1234567890`, `1L`
> List: `item1,item2,item3`
>
> In addition to that, you can escape quotes (`\"`, `\'`) and commas (`\,`) to treat values as string literals:
> Integer as string: `\'123\'`
> List with an integer, an integer as a string and a string with a comma: `123,\'123\',str\,ing`
## 📦 Install an app manually

```bash
java -jar revanced-cli.jar utility install -a input.apk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,11 @@ internal object ListPatchesCommand : Runnable {
} ?: append("Key: $key")

values?.let { values ->
appendLine("\nValid values:")
appendLine("\nPossible values:")
append(values.map { "${it.value} (${it.key})" }.joinToString("\n").prependIndent("\t"))
}

append("\nType: $type")
}

fun IndexedValue<Patch<*>>.buildString() =
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/app/revanced/cli/command/MainCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ private object CLIVersionProvider : IVersionProvider {
versionProvider = CLIVersionProvider::class,
subcommands = [
PatchCommand::class,
OptionsCommand::class,
ListPatchesCommand::class,
ListCompatibleVersions::class,
UtilityCommand::class,
Expand Down
62 changes: 0 additions & 62 deletions src/main/kotlin/app/revanced/cli/command/OptionsCommand.kt

This file was deleted.

Loading

0 comments on commit 2138376

Please sign in to comment.