Better properties handling.
This commit is contained in:
parent
fb3a5ce5d2
commit
56fcbfe165
@ -12,19 +12,15 @@ import java.nio.file.Paths
|
|||||||
import java.time.LocalDate
|
import java.time.LocalDate
|
||||||
import java.time.Month
|
import java.time.Month
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
var cookie = "<insert your session cookie here or store in gradle.properties>"
|
var cookie = "<insert your session cookie here or store in gradle.properties>"
|
||||||
|
|
||||||
if (Files.exists(Paths.get("gradle.properties"))) {
|
if (Files.exists(Paths.get("gradle.properties"))) {
|
||||||
val cookieFromProps = Files.readAllLines(Paths.get("gradle.properties"))
|
val props = Properties()
|
||||||
.map { it.split("=") }
|
props.load(Files.newBufferedReader(Paths.get("gradle.properties")))
|
||||||
.filter { it.size == 2 }
|
cookie = props.getProperty("cookie", cookie)
|
||||||
.filter { it[0] == "cookie" }
|
|
||||||
.map { it[1] }.firstOrNull()
|
|
||||||
if (cookieFromProps != null) {
|
|
||||||
cookie = cookieFromProps
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val downloader = Downloader(2023, "aoc2023", cookie)
|
val downloader = Downloader(2023, "aoc2023", cookie)
|
||||||
|
Loading…
Reference in New Issue
Block a user