From d2bdf6c69ed043221589b7259cced8abe7af4133 Mon Sep 17 00:00:00 2001 From: Jazzpirate Date: Fri, 3 Nov 2023 21:05:02 +0100 Subject: [PATCH] probably fix in frameit --- .../frameit/communication/server/Server.scala | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/frameit-mmt/src/info/kwarc/mmt/frameit/communication/server/Server.scala b/src/frameit-mmt/src/info/kwarc/mmt/frameit/communication/server/Server.scala index 658dc8a630..038ba2ec23 100644 --- a/src/frameit-mmt/src/info/kwarc/mmt/frameit/communication/server/Server.scala +++ b/src/frameit-mmt/src/info/kwarc/mmt/frameit/communication/server/Server.scala @@ -23,19 +23,26 @@ object Server extends IOApp /*with TwitterServer with EndpointModule[IO]*/ { private val archiveRoot = flag("archive-root", "", "Path to archive root (preferably without spaces), e.g. to a clone of ") */ - def archiveRoot(): String = "C:/Users/nroux/Desktop/kwarc/mmt-archives" - - def bindAddress(): String = ":8085" - - def debug(): Boolean = true + def debug(): Boolean = _debug + private var _debug: Boolean = false + + private case class Args(bindAddress: String = "", archiveRoot: String = "") + private def parse_args(args:List[String],ret:Args): Args = { + args match { + case Nil => ret + case "-debug" :: rest => _debug = true; parse_args(rest,ret) + case "-bind" :: addr :: rest => parse_args(rest,ret.copy(bindAddress = addr)) + case "-archive-root" :: root :: rest => parse_args(rest,ret.copy(archiveRoot = root)) + case _ :: rest => parse_args(rest,ret) + } + } override def run(args: List[String]): IO[ExitCode] = { + val args_ = parse_args(args,Args()) if (debug()) { println("Server started in debugging mode.") } - - val state = initServerState(File(archiveRoot())) - - ConcreteServerEndpoints.createServer(state, bindAddress()).useForever.as(ExitCode.Success) + val state = initServerState(File(args_.archiveRoot)) + ConcreteServerEndpoints.createServer(state, args_.bindAddress).useForever.as(ExitCode.Success) } def initServerState(archiveRoot: File): ServerState = {