diff --git a/kt/aoc2024-exe/src/commonMain/kotlin/com/github/ephemient/aoc2024/exe/CommonMain.kt b/kt/aoc2024-exe/src/commonMain/kotlin/com/github/ephemient/aoc2024/exe/CommonMain.kt index 4d3a44a0..9a01746b 100644 --- a/kt/aoc2024-exe/src/commonMain/kotlin/com/github/ephemient/aoc2024/exe/CommonMain.kt +++ b/kt/aoc2024-exe/src/commonMain/kotlin/com/github/ephemient/aoc2024/exe/CommonMain.kt @@ -3,8 +3,7 @@ package com.github.ephemient.aoc2024.exe import com.github.ephemient.aoc2024.days internal suspend fun mainImpl(args: Array) { - for (day in days) { - if ((args.isNotEmpty() || day.skipByDefault) && day.name !in args) continue + for (day in days.filter { it.name in args }.ifEmpty { days }) { println("Day ${day.name}") for (part in day.solver(getDayInput(day.day))) println(part()) println() diff --git a/kt/aoc2024-exe/src/jsMain/kotlin/com/github/ephemient/aoc2024/exe/JsMain.kt b/kt/aoc2024-exe/src/jsMain/kotlin/com/github/ephemient/aoc2024/exe/JsMain.kt index 2e9a1355..32834f5a 100644 --- a/kt/aoc2024-exe/src/jsMain/kotlin/com/github/ephemient/aoc2024/exe/JsMain.kt +++ b/kt/aoc2024-exe/src/jsMain/kotlin/com/github/ephemient/aoc2024/exe/JsMain.kt @@ -3,5 +3,5 @@ package com.github.ephemient.aoc2024.exe import js.globals.globalThis suspend fun main() { - mainImpl(with(globalThis.asDynamic().process.argv.unsafeCast>()) { copyOfRange(2, size) }) + mainImpl(globalThis.asDynamic().process.argv.unsafeCast>()) } diff --git a/kt/aoc2024-exe/src/wasmJsMain/kotlin/com/github/ephemient/aoc2024/exe/WasmJsMain.kt b/kt/aoc2024-exe/src/wasmJsMain/kotlin/com/github/ephemient/aoc2024/exe/WasmJsMain.kt index f02523d7..9fc5a0cd 100644 --- a/kt/aoc2024-exe/src/wasmJsMain/kotlin/com/github/ephemient/aoc2024/exe/WasmJsMain.kt +++ b/kt/aoc2024-exe/src/wasmJsMain/kotlin/com/github/ephemient/aoc2024/exe/WasmJsMain.kt @@ -1,8 +1,9 @@ package com.github.ephemient.aoc2024.exe -private fun argv(): JsArray = js("process.argv") +@JsModule("node:process") +private external val argv: JsArray suspend fun main() { - val argv = argv() - mainImpl(Array(argv.length - 2) { argv[it + 2].toString() }) + val argv = argv + mainImpl(Array(argv.length) { argv[it].toString() }) } diff --git a/kt/aoc2024-exe/src/wasmWasiMain/kotlin/com/github/ephemient/aoc2024/exe/WasmWasiMain.kt b/kt/aoc2024-exe/src/wasmWasiMain/kotlin/com/github/ephemient/aoc2024/exe/WasmWasiMain.kt index 75d079a9..58c6a531 100644 --- a/kt/aoc2024-exe/src/wasmWasiMain/kotlin/com/github/ephemient/aoc2024/exe/WasmWasiMain.kt +++ b/kt/aoc2024-exe/src/wasmWasiMain/kotlin/com/github/ephemient/aoc2024/exe/WasmWasiMain.kt @@ -1,6 +1,5 @@ package com.github.ephemient.aoc2024.exe suspend fun main() { - val argv = argv() - mainImpl(argv.copyOfRange(2, argv.size)) + mainImpl(argv()) }