From f4f6f767161e2252b532a56387beb40ea2100864 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Thu, 27 Aug 2026 09:46:20 +0200 Subject: [PATCH] feat: add CLI entry point --- src/main/kotlin/kestrel/cli/Main.kt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/kotlin/kestrel/cli/Main.kt diff --git a/src/main/kotlin/kestrel/cli/Main.kt b/src/main/kotlin/kestrel/cli/Main.kt new file mode 100644 index 0000000..777d038 --- /dev/null +++ b/src/main/kotlin/kestrel/cli/Main.kt @@ -0,0 +1,28 @@ +package kestrel.cli + +import java.io.File +import kestrel.persistence.Persistence + +fun main(arguments: Array) { + var dataDir: File? = null + var scriptPath: String? = null + var index = 0 + while (index < arguments.size) { + val argument = arguments[index] + when { + argument == "--data" -> { + dataDir = File(arguments[index + 1]); index += 2 + } + argument.startsWith("--data=") -> { + dataDir = File(argument.substringAfter('=')); index += 1 + } + else -> { + scriptPath = argument; index += 1 + } + } + } + val persistence = dataDir?.let { Persistence(it) } + val repl = Repl(persistence = persistence) + val reader = if (scriptPath != null) File(scriptPath).bufferedReader() else System.`in`.bufferedReader() + reader.use { repl.run(it) } +}