From a8653fdec2f476edafd42e17a098d55cb41532e1 Mon Sep 17 00:00:00 2001 From: Chris Kipp Date: Fri, 26 Jan 2024 10:19:30 +0100 Subject: [PATCH] fix: make sure `runEither` isn't calling itself It looks like this was overlooked and the overloaded `runEither` is just constantly calling itself resulting in a stack overflow. This changes it to call the newly created `runEither` with the `nameMapper` which I believe is the intended flow. fixes #106 --- mainargs/src/Parser.scala | 3 ++- mainargs/test/src/ParserTests.scala | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mainargs/src/Parser.scala b/mainargs/src/Parser.scala index 790d781..b9288c9 100644 --- a/mainargs/src/Parser.scala +++ b/mainargs/src/Parser.scala @@ -213,7 +213,8 @@ class ParserForMethods[B](val mains: MethodMains[B]) { autoPrintHelpAndExit, customNames, customDocs, - sorted + sorted, + Util.kebabCaseNameMapper ) @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") def runRaw( diff --git a/mainargs/test/src/ParserTests.scala b/mainargs/test/src/ParserTests.scala index 2536293..b7e6ba2 100644 --- a/mainargs/test/src/ParserTests.scala +++ b/mainargs/test/src/ParserTests.scala @@ -54,5 +54,8 @@ object ParserTests extends TestSuite { classParser.constructEither(Array("--code", "println(1)")) ==> Right(ClassBase(code = Some("println(1)"), other = "hello")) } + test("simplerunOrExit") { + singleMethodParser.runOrExit(Array("-i", "2")) ==> "lolslols" + } } }