1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-22 00:27:14 +00:00

refactor and fixes

This commit is contained in:
InsanusMokrassar 2024-12-05 21:04:54 +06:00
parent 819982473a
commit 9cde4927ce
5 changed files with 6 additions and 6 deletions

View File

@ -35,7 +35,7 @@ val templatesFolders = mutableListOf<File>()
var extensions: List<String>? = null
var skipPrompts: Boolean = false
val commandLineArgs = mutableMapOf<String, String>()
val globalEnvs = System.getenv()
val globalEnvs = System.getenv().toMutableMap()
fun String.replaceWithVariables(envs: Map<String, String>): String {
var currentString = this
@ -183,7 +183,7 @@ fun readParameters() {
readParameters()
val envs: MutableMap<String, String> = envFile ?.let { readEnvs(it.readText(), null) } ?.toMutableMap() ?: mutableMapOf()
val envs: MutableMap<String, String> = (envFile ?.let { readEnvs(it.readText(), null) } ?: (globalEnvs + commandLineArgs)).toMutableMap()
println(
"""

View File

@ -10,9 +10,11 @@ val rfAbsolutePath = rootFolder.absolutePath
fun generateEvent(eventName: String, callbacks: String) {
val uppercaseEventName = eventName.take(1).uppercase() + eventName.drop(1)
val command = "${rfAbsolutePath}/.templates/generator.kts -s -a \"event_name=$eventName\" -a \"event_name_uppercase=$uppercaseEventName\" -a \"callback_args=$callbacks\" --env \"${rfAbsolutePath}/.templates/events/.env\" -o \"./\" -ex \"kt\" \"${rfAbsolutePath}/.templates/events/\""
val subpackage = eventName.map { if (it.isUpperCase()) "_${it.lowercase()}" else it }.joinToString("")
val command = "${rfAbsolutePath}/.templates/generator.kts -s -a \"subpackage=$subpackage\" -a \"event_name=$eventName\" -a \"event_name_uppercase=$uppercaseEventName\" -a \"callback_args=$callbacks\" -o \"./\" -ex \"kt\" \"${rfAbsolutePath}/.templates/{{\$subpackage}}\""
Runtime.getRuntime().exec(command).waitFor()
println(command)
println(Runtime.getRuntime().exec(command).waitFor())
}
val eventsList: JsonArray = Json.parseToJsonElement(File("EventsList.json").readText()).jsonArray
@ -23,5 +25,3 @@ eventsList.forEach {
it.jsonObject["callback"] ?.jsonPrimitive ?.content ?: ""
)
}
println(eventsList.toString())