Last active
July 9, 2020 15:54
-
-
Save mkj-gram/a5e19b3389563183ad0516438be16df9 to your computer and use it in GitHub Desktop.
Command Builder
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
package com.example.mylibrary | |
/** CommandBuilderBase contains options common for D8 and R8. */ | |
abstract class CommandBuilderBase { | |
internal var minApi: Int = 0 | |
internal var inputs: MutableList<String> = mutableListOf() | |
abstract fun getCommandName(): String | |
abstract fun getExtraArgs(): String | |
fun build(): String { | |
val inputArgs = inputs.joinToString(separator = " ") | |
return "${getCommandName()} --min-api=$minApi $inputArgs ${getExtraArgs()}" | |
} | |
} | |
fun <T : CommandBuilderBase> T.setMinApi(api: Int): T { | |
minApi = api | |
return this | |
} | |
fun <T : CommandBuilderBase> T.addInput(input: String): T { | |
inputs.add(input) | |
return this | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment