From a9da25e2583cab214d8783e4671ac0b083588929 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 12 Oct 2024 13:23:22 +0000 Subject: [PATCH 1/3] Update scalafmt-core to 3.7.17 --- .scalafmt.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 574d353..767c539 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version = "3.7.3" +version = "3.7.17" project.git = true From 1d3a9ba3d19b8a74d6523a4d5f0c2f733cea5ed3 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 12 Oct 2024 13:23:31 +0000 Subject: [PATCH 2/3] Reformat with scalafmt 3.7.17 Executed command: scalafmt --non-interactive --- mainargs/src-2/Macros.scala | 2 +- mainargs/src-3/Macros.scala | 116 +++++++++------ ...rserForClassCompanionVersionSpecific.scala | 2 +- ...erForMethodsCompanionVersionSpecific.scala | 2 +- mainargs/src/Invoker.scala | 21 ++- mainargs/src/Parser.scala | 60 +++++--- mainargs/src/Renderer.scala | 41 +++-- mainargs/src/TokenGrouping.scala | 45 +++--- mainargs/src/TokensReader.scala | 140 +++++++++++------- mainargs/src/Util.scala | 4 +- mainargs/test/src-jvm-2/AmmoniteTests.scala | 4 +- mainargs/test/src/Checker.scala | 6 +- mainargs/test/src/ClassWithDefaultTests.scala | 6 +- mainargs/test/src/ConstantTests.scala | 2 +- mainargs/test/src/CoreTests.scala | 35 +++-- mainargs/test/src/DashedArgumentName.scala | 18 ++- mainargs/test/src/EqualsSyntaxTests.scala | 14 +- mainargs/test/src/FlagTests.scala | 12 +- mainargs/test/src/InvocationArgs.scala | 66 ++++----- mainargs/test/src/IssueTests.scala | 8 +- mainargs/test/src/VarargsBaseTests.scala | 2 +- 21 files changed, 360 insertions(+), 246 deletions(-) diff --git a/mainargs/src-2/Macros.scala b/mainargs/src-2/Macros.scala index 499f973..68db258 100755 --- a/mainargs/src-2/Macros.scala +++ b/mainargs/src-2/Macros.scala @@ -98,7 +98,7 @@ class Macros(val c: Context) { val defaults = for ((arg0, i) <- flattenedArgLists.zipWithIndex) yield { val arg = TermName(c.freshName()) - hasDefault(i) match{ + hasDefault(i) match { case None => q"_root_.scala.None" case Some(defaultName) => q"_root_.scala.Some[$curCls => ${arg0.info}](($arg: $curCls) => $arg.${newTermName(defaultName)}: ${arg0.info})" diff --git a/mainargs/src-3/Macros.scala b/mainargs/src-3/Macros.scala index 67e1542..bacff7c 100644 --- a/mainargs/src-3/Macros.scala +++ b/mainargs/src-3/Macros.scala @@ -11,8 +11,9 @@ object Macros { val annotatedMethodsWithMainAnnotations = allMethods.flatMap { methodSymbol => methodSymbol.getAnnotation(mainAnnotation).map(methodSymbol -> _) }.sortBy(_._1.pos.map(_.start)) - val mainDatas = Expr.ofList(annotatedMethodsWithMainAnnotations.map { (annotatedMethod, mainAnnotationInstance) => - createMainData[Any, B](annotatedMethod, mainAnnotationInstance) + val mainDatas = Expr.ofList(annotatedMethodsWithMainAnnotations.map { + (annotatedMethod, mainAnnotationInstance) => + createMainData[Any, B](annotatedMethod, mainAnnotationInstance) }) '{ @@ -26,13 +27,13 @@ object Macros { import quotes.reflect._ val typeReprOfB = TypeRepr.of[B] val companionModule = typeReprOfB match { - case TypeRef(a,b) => TermRef(a,b) + case TypeRef(a, b) => TermRef(a, b) } val typeSymbolOfB = typeReprOfB.typeSymbol val companionModuleType = typeSymbolOfB.companionModule.tree.asInstanceOf[ValDef].tpt.tpe.asType val companionModuleExpr = Ident(companionModule).asExpr val mainAnnotationInstance = typeSymbolOfB.getAnnotation(mainAnnotation).getOrElse { - '{new mainargs.main()}.asTerm // construct a default if not found. + '{ new mainargs.main() }.asTerm // construct a default if not found. } val ctor = typeSymbolOfB.primaryConstructor val ctorParams = ctor.paramSymss.flatten @@ -58,13 +59,13 @@ object Macros { // parameters, so use those for getting the annotations instead TypeRepr.of[B].typeSymbol.primaryConstructor.paramSymss ) - val erasedMainData = '{$mainData.asInstanceOf[MainData[B, Any]]} + val erasedMainData = '{ $mainData.asInstanceOf[MainData[B, Any]] } '{ new ParserForClass[B]($erasedMainData, () => ${ Ident(companionModule).asExpr }) } } - def createMainData[T: Type, B: Type](using Quotes) - (method: quotes.reflect.Symbol, - mainAnnotation: quotes.reflect.Term): Expr[MainData[T, B]] = { + def createMainData[T: Type, B: Type](using + Quotes + )(method: quotes.reflect.Symbol, mainAnnotation: quotes.reflect.Term): Expr[MainData[T, B]] = { createMainData[T, B](method, mainAnnotation, method.paramSymss) } @@ -73,9 +74,12 @@ object Macros { import quotes.reflect.* tpe match { case AnnotatedType(AppliedType(_, Seq(arg)), x) // Scala 3 repeated parameter - if x.tpe =:= defn.RepeatedAnnot.typeRef => Some(arg) - case AppliedType(TypeRef(pre, ""), Seq(arg)) // Scala 2 repeated parameter, can be read from Scala 3 - if pre =:= defn.ScalaPackage.termRef => Some(arg) + if x.tpe =:= defn.RepeatedAnnot.typeRef => Some(arg) + case AppliedType( + TypeRef(pre, ""), + Seq(arg) + ) // Scala 2 repeated parameter, can be read from Scala 3 + if pre =:= defn.ScalaPackage.termRef => Some(arg) case _ => None } } @@ -87,14 +91,18 @@ object Macros { } } - def createMainData[T: Type, B: Type](using Quotes) - (method: quotes.reflect.Symbol, - mainAnnotation: quotes.reflect.Term, - annotatedParamsLists: List[List[quotes.reflect.Symbol]]): Expr[MainData[T, B]] = { + def createMainData[T: Type, B: Type](using Quotes)( + method: quotes.reflect.Symbol, + mainAnnotation: quotes.reflect.Term, + annotatedParamsLists: List[List[quotes.reflect.Symbol]] + ): Expr[MainData[T, B]] = { import quotes.reflect.* - val params = method.paramSymss.headOption.getOrElse(report.throwError("Multiple parameter lists not supported")) - val defaultParams = if (params.exists(_.flags.is(Flags.HasDefault))) getDefaultParams(method) else Map.empty + val params = method.paramSymss.headOption.getOrElse( + report.throwError("Multiple parameter lists not supported") + ) + val defaultParams = + if (params.exists(_.flags.is(Flags.HasDefault))) getDefaultParams(method) else Map.empty val argSigsExprs = params.zip(annotatedParamsLists.flatten).map { paramAndAnnotParam => val param = paramAndAnnotParam._1 val annotParam = paramAndAnnotParam._2 @@ -104,7 +112,9 @@ object Macros { case VarargTypeRepr(AsType('[t])) => TypeRepr.of[Leftover[t]] case _ => paramTpe } - val arg = annotParam.getAnnotation(argAnnotation).map(_.asExprOf[mainargs.arg]).getOrElse('{ new mainargs.arg() }) + val arg = annotParam.getAnnotation(argAnnotation).map(_.asExprOf[mainargs.arg]).getOrElse('{ + new mainargs.arg() + }) readerTpe.asType match { case '[t] => def applyAndCast(f: Expr[Any] => Expr[Any], arg: Expr[B]): Expr[t] = { @@ -119,10 +129,10 @@ object Macros { case err: Exception => report.errorAndAbort( s"""Failed to convert default value for parameter ${param.name}, - |expected type: ${paramTpe.show}, - |but default value ${expr.show} is of type: ${expr.asTerm.tpe.widen.show} - |while converting type caught an exception with message: ${err.getMessage} - |There might be a bug in mainargs.""".stripMargin, + |expected type: ${paramTpe.show}, + |but default value ${expr.show} is of type: ${expr.asTerm.tpe.widen.show} + |while converting type caught an exception with message: ${err.getMessage} + |There might be a bug in mainargs.""".stripMargin, param.pos.getOrElse(Position.ofMacroExpansion) ) recoveredType @@ -139,7 +149,10 @@ object Macros { method.pos.getOrElse(Position.ofMacroExpansion) ) } - '{ (ArgSig.create[t, B](${ Expr(param.name) }, ${ arg }, ${ defaultParam })(using ${ tokensReader })) } + '{ + (ArgSig.create[t, B](${ Expr(param.name) }, ${ arg }, ${ defaultParam })(using + ${ tokensReader })) + } } } val argSigs = Expr.ofList(argSigsExprs) @@ -151,28 +164,35 @@ object Macros { '{ (b: B, params: Seq[Any]) => ${ callOf('b, 'params) } } } - '{ MainData.create[T, B](${ Expr(method.name) }, ${ mainAnnotation.asExprOf[mainargs.main] }, ${ argSigs }, ${ invokeRaw }) } + '{ + MainData.create[T, B]( + ${ Expr(method.name) }, + ${ mainAnnotation.asExprOf[mainargs.main] }, + ${ argSigs }, + ${ invokeRaw } + ) + } } - /** Call a method given by its symbol. - * - * E.g. - * - * assuming: - * - * def foo(x: Int, y: String)(z: Int) - * - * val argss: List[List[Any]] = ??? - * - * then: - * - * call(, '{argss}) - * - * will expand to: - * - * foo(argss(0)(0), argss(0)(1))(argss(1)(0)) - * - */ + /** + * Call a method given by its symbol. + * + * E.g. + * + * assuming: + * + * def foo(x: Int, y: String)(z: Int) + * + * val argss: List[List[Any]] = ??? + * + * then: + * + * call(, '{argss}) + * + * will expand to: + * + * foo(argss(0)(0), argss(0)(1))(argss(1)(0)) + */ private def call(using Quotes)( methodOwner: Expr[Any], method: quotes.reflect.Symbol, @@ -197,7 +217,7 @@ object Macros { for (i <- params.indices.toList) yield { val param = params(i) val tpe = methodType.memberType(param) - val untypedRef = '{ $ref(${Expr(i)}) } + val untypedRef = '{ $ref(${ Expr(i) }) } tpe match { case VarargTypeRepr(AsType('[t])) => Typed( @@ -205,7 +225,7 @@ object Macros { Inferred(AppliedType(defn.RepeatedParamClass.typeRef, List(TypeRepr.of[t]))) ) case _ => tpe.asType match - case '[t] => '{ $untypedRef.asInstanceOf[t] }.asTerm + case '[t] => '{ $untypedRef.asInstanceOf[t] }.asTerm } } @@ -213,7 +233,9 @@ object Macros { } /** Lookup default values for a method's parameters. */ - private def getDefaultParams(using Quotes)(method: quotes.reflect.Symbol): Map[quotes.reflect.Symbol, Expr[Any] => Expr[Any]] = { + private def getDefaultParams(using + Quotes + )(method: quotes.reflect.Symbol): Map[quotes.reflect.Symbol, Expr[Any] => Expr[Any]] = { // Copy pasted from Cask. // https://github.com/com-lihaoyi/cask/blob/65b9c8e4fd528feb71575f6e5ef7b5e2e16abbd9/cask/src-3/cask/router/Macros.scala#L38 import quotes.reflect._ @@ -226,7 +248,7 @@ object Macros { val idents = method.owner.tree.asInstanceOf[ClassDef].body - idents.foreach{ + idents.foreach { case deff @ DefDef(Name(idx), _, _, _) => val expr = (owner: Expr[Any]) => Select(owner.asTerm, deff.symbol).asExpr defaults += (params(idx.toInt - 1) -> expr) diff --git a/mainargs/src-3/ParserForClassCompanionVersionSpecific.scala b/mainargs/src-3/ParserForClassCompanionVersionSpecific.scala index ae1ac2d..b21a649 100644 --- a/mainargs/src-3/ParserForClassCompanionVersionSpecific.scala +++ b/mainargs/src-3/ParserForClassCompanionVersionSpecific.scala @@ -2,6 +2,6 @@ package mainargs import scala.language.experimental.macros -private [mainargs] trait ParserForClassCompanionVersionSpecific { +private[mainargs] trait ParserForClassCompanionVersionSpecific { inline def apply[T]: ParserForClass[T] = ${ Macros.parserForClass[T] } } diff --git a/mainargs/src-3/ParserForMethodsCompanionVersionSpecific.scala b/mainargs/src-3/ParserForMethodsCompanionVersionSpecific.scala index c66f286..5076bef 100644 --- a/mainargs/src-3/ParserForMethodsCompanionVersionSpecific.scala +++ b/mainargs/src-3/ParserForMethodsCompanionVersionSpecific.scala @@ -1,5 +1,5 @@ package mainargs -private [mainargs] trait ParserForMethodsCompanionVersionSpecific { +private[mainargs] trait ParserForMethodsCompanionVersionSpecific { inline def apply[B](base: B): ParserForMethods[B] = ${ Macros.parserForMethods[B]('base) } } diff --git a/mainargs/src/Invoker.scala b/mainargs/src/Invoker.scala index 732dc31..3e4ccda 100644 --- a/mainargs/src/Invoker.scala +++ b/mainargs/src/Invoker.scala @@ -5,7 +5,7 @@ object Invoker { cep: TokensReader.Class[T], args: Seq[String], allowPositional: Boolean, - allowRepeats: Boolean, + allowRepeats: Boolean ): Result[T] = construct(cep, args, allowPositional, allowRepeats, Util.nullNameMapper) def construct[T]( @@ -40,9 +40,9 @@ object Invoker { Right(ParamResult.Success(Flag(kvs.contains(a)).asInstanceOf[T])) case r: TokensReader.Simple[T] => Right(makeReadCall(kvs, base, a, r)) case r: TokensReader.Constant[T] => Right(r.read() match { - case Left(s) => ParamResult.Failure(Seq(Result.ParamError.Failed(a, Nil, s))) - case Right(v) => ParamResult.Success(v) - }) + case Left(s) => ParamResult.Failure(Seq(Result.ParamError.Failed(a, Nil, s))) + case Right(v) => ParamResult.Success(v) + }) case r: TokensReader.Leftover[T, _] => Right(makeReadVarargsCall(a, extras, r)) case r: TokensReader.Class[T] => Left( @@ -91,7 +91,8 @@ object Invoker { mains: MethodMains[B], args: Seq[String], allowPositional: Boolean, - allowRepeats: Boolean): Either[Result.Failure.Early, (MainData[Any, B], Result[Any])] = { + allowRepeats: Boolean + ): Either[Result.Failure.Early, (MainData[Any, B], Result[Any])] = { runMains(mains, args, allowPositional, allowRepeats, Util.nullNameMapper) } def runMains[B]( @@ -126,16 +127,20 @@ object Invoker { case Seq(main) => groupArgs(main, args) case multiple => args.toList match { - case List() => Left(Result.Failure.Early.SubcommandNotSpecified(multiple.map(_.name(nameMapper)))) + case List() => + Left(Result.Failure.Early.SubcommandNotSpecified(multiple.map(_.name(nameMapper)))) case head :: tail => if (head.startsWith("-")) { Left(Result.Failure.Early.SubcommandSelectionDashes(head)) } else { - multiple.find{ m => + multiple.find { m => val name = m.name(nameMapper) name == head || (m.mainName.isEmpty && m.defaultName == head) } match { - case None => Left(Result.Failure.Early.UnableToFindSubcommand(multiple.map(_.name(nameMapper)), head)) + case None => Left(Result.Failure.Early.UnableToFindSubcommand( + multiple.map(_.name(nameMapper)), + head + )) case Some(main) => groupArgs(main, tail) } } diff --git a/mainargs/src/Parser.scala b/mainargs/src/Parser.scala index ef92420..8e8fdf8 100644 --- a/mainargs/src/Parser.scala +++ b/mainargs/src/Parser.scala @@ -13,7 +13,8 @@ class ParserForMethods[B](val mains: MethodMains[B]) { docsOnNewLine: Boolean, customNames: Map[String, String], customDocs: Map[String, String], - sorted: Boolean): String = { + sorted: Boolean + ): String = { helpText(totalWidth, docsOnNewLine, customNames, customDocs, sorted, Util.kebabCaseNameMapper) } @@ -115,7 +116,7 @@ class ParserForMethods[B](val mains: MethodMains[B]) { docsOnNewLine: Boolean, autoPrintHelpAndExit: Option[(Int, PrintStream)], customNames: Map[String, String], - customDocs: Map[String, String], + customDocs: Map[String, String] ): Any = runOrThrow( args, allowPositional, @@ -173,7 +174,14 @@ class ParserForMethods[B](val mains: MethodMains[B]) { ): Either[String, Any] = { if (autoPrintHelpAndExit.nonEmpty && args.take(1) == Seq("--help")) { val (exitCode, outputStream) = autoPrintHelpAndExit.get - outputStream.println(helpText(totalWidth, docsOnNewLine, customNames, customDocs, sorted, nameMapper)) + outputStream.println(helpText( + totalWidth, + docsOnNewLine, + customNames, + customDocs, + sorted, + nameMapper + )) Compat.exit(exitCode) } else runRaw0(args, allowPositional, allowRepeats, nameMapper) match { case Left(err) => Left(Renderer.renderEarlyError(err)) @@ -222,21 +230,19 @@ class ParserForMethods[B](val mains: MethodMains[B]) { sorted = false ) - - @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") def runEither( - args: Seq[String], - allowPositional: Boolean, - allowRepeats: Boolean, - totalWidth: Int, - printHelpOnExit: Boolean, - docsOnNewLine: Boolean, - autoPrintHelpAndExit: Option[(Int, PrintStream)], - customNames: Map[String, String], - customDocs: Map[String, String], - sorted: Boolean - ): Either[String, Any] = runEither( + args: Seq[String], + allowPositional: Boolean, + allowRepeats: Boolean, + totalWidth: Int, + printHelpOnExit: Boolean, + docsOnNewLine: Boolean, + autoPrintHelpAndExit: Option[(Int, PrintStream)], + customNames: Map[String, String], + customDocs: Map[String, String], + sorted: Boolean + ): Either[String, Any] = runEither( args, allowPositional, allowRepeats, @@ -253,9 +259,12 @@ class ParserForMethods[B](val mains: MethodMains[B]) { def runRaw( args: Seq[String], allowPositional: Boolean, - allowRepeats: Boolean, + allowRepeats: Boolean ): Result[Any] = runRaw( - args, allowPositional, allowRepeats, Util.kebabCaseNameMapper + args, + allowPositional, + allowRepeats, + Util.kebabCaseNameMapper ) def runRaw( args: Seq[String], @@ -273,7 +282,7 @@ class ParserForMethods[B](val mains: MethodMains[B]) { def runRaw0( args: Seq[String], allowPositional: Boolean, - allowRepeats: Boolean, + allowRepeats: Boolean ): Either[Result.Failure.Early, (MainData[_, B], Result[Any])] = runRaw0( args, allowPositional, @@ -303,7 +312,9 @@ class ParserForClass[T](val main: MainData[T, Any], val companion: () => Any) docsOnNewLine: Boolean, customName: String, customDoc: String, - sorted: Boolean): String = helpText(totalWidth, docsOnNewLine, customName, customDoc, sorted, Util.kebabCaseNameMapper) + sorted: Boolean + ): String = + helpText(totalWidth, docsOnNewLine, customName, customDoc, sorted, Util.kebabCaseNameMapper) def helpText( totalWidth: Int = 100, @@ -345,7 +356,8 @@ class ParserForClass[T](val main: MainData[T, Any], val companion: () => Any) docsOnNewLine: Boolean, autoPrintHelpAndExit: Option[(Int, PrintStream)], customName: String, - customDoc: String): T = constructOrExit( + customDoc: String + ): T = constructOrExit( args, allowPositional, allowRepeats, @@ -400,7 +412,7 @@ class ParserForClass[T](val main: MainData[T, Any], val companion: () => Any) docsOnNewLine: Boolean, autoPrintHelpAndExit: Option[(Int, PrintStream)], customName: String, - customDoc: String, + customDoc: String ): T = constructOrThrow( args, allowPositional, @@ -453,7 +465,7 @@ class ParserForClass[T](val main: MainData[T, Any], val companion: () => Any) autoPrintHelpAndExit: Option[(Int, PrintStream)], customName: String, customDoc: String, - sorted: Boolean, + sorted: Boolean ): Either[String, T] = constructEither( args, allowPositional, @@ -532,7 +544,7 @@ class ParserForClass[T](val main: MainData[T, Any], val companion: () => Any) def constructRaw( args: Seq[String], allowPositional: Boolean, - allowRepeats: Boolean, + allowRepeats: Boolean ): Result[T] = constructRaw( args, allowPositional, diff --git a/mainargs/src/Renderer.scala b/mainargs/src/Renderer.scala index bbde53b..715b940 100644 --- a/mainargs/src/Renderer.scala +++ b/mainargs/src/Renderer.scala @@ -26,7 +26,8 @@ object Renderer { case r: TokensReader.Simple[_] => val shortPrefix = arg.shortName.map(c => s"-$c") val typeSuffix = s"<${r.shortName}>" - val nameSuffix = if (arg.positional) arg.longName(nameMapper) else arg.longName(nameMapper).map(s => s"--$s") + val nameSuffix = + if (arg.positional) arg.longName(nameMapper) else arg.longName(nameMapper).map(s => s"--$s") (shortPrefix ++ nameSuffix ++ Seq(typeSuffix)).mkString(" ") case r: TokensReader.Leftover[_, _] => @@ -36,14 +37,15 @@ object Renderer { /** * Returns a `Some[string]` with the sortable string or a `None` if it is an leftover. */ - private def sortableName(arg: ArgSig, nameMapper: String => Option[String]): Option[String] = arg match { - case arg: ArgSig if arg.reader.isLeftover => None - - case a: ArgSig => - a.shortName.map(_.toString).orElse(a.longName(nameMapper)).orElse(Some("")) - case a: ArgSig => - a.longName(nameMapper) - } + private def sortableName(arg: ArgSig, nameMapper: String => Option[String]): Option[String] = + arg match { + case arg: ArgSig if arg.reader.isLeftover => None + + case a: ArgSig => + a.shortName.map(_.toString).orElse(a.longName(nameMapper)).orElse(Some("")) + case a: ArgSig => + a.longName(nameMapper) + } object ArgOrd extends math.Ordering[ArgSig] { override def compare(x: ArgSig, y: ArgSig): Int = @@ -58,7 +60,8 @@ object Renderer { def renderArg( arg: ArgSig, leftOffset: Int, - wrappedWidth: Int): (String, String) = renderArg(arg, leftOffset, wrappedWidth, Util.kebabCaseNameMapper) + wrappedWidth: Int + ): (String, String) = renderArg(arg, leftOffset, wrappedWidth, Util.kebabCaseNameMapper) def renderArg( arg: ArgSig, @@ -76,8 +79,16 @@ object Renderer { docsOnNewLine: Boolean, customNames: Map[String, String], customDocs: Map[String, String], - sorted: Boolean, - ): String = formatMainMethods(mainMethods, totalWidth, docsOnNewLine, customNames, customDocs, sorted, Util.kebabCaseNameMapper) + sorted: Boolean + ): String = formatMainMethods( + mainMethods, + totalWidth, + docsOnNewLine, + customNames, + customDocs, + sorted, + Util.kebabCaseNameMapper + ) def formatMainMethods( mainMethods: Seq[MainData[_, _]], @@ -137,7 +148,7 @@ object Renderer { totalWidth: Int, docsOnNewLine: Boolean, customNames: Map[String, String], - customDocs: Map[String, String], + customDocs: Map[String, String] ): String = formatMainMethods( mainMethods, totalWidth, @@ -207,7 +218,7 @@ object Renderer { docsOnNewLine, customName, customDoc, - sorted = true, + sorted = true ) @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") @@ -279,7 +290,7 @@ object Renderer { docsOnNewLine: Boolean, customName: Option[String], customDoc: Option[String], - sorted: Boolean, + sorted: Boolean ): String = renderResult( main, result, diff --git a/mainargs/src/TokenGrouping.scala b/mainargs/src/TokenGrouping.scala index faa3d96..2d99192 100644 --- a/mainargs/src/TokenGrouping.scala +++ b/mainargs/src/TokenGrouping.scala @@ -11,7 +11,7 @@ object TokenGrouping { argSigs: Seq[(ArgSig, TokensReader.Terminal[_])], allowPositional: Boolean, allowRepeats: Boolean, - allowLeftover: Boolean, + allowLeftover: Boolean ): Result[TokenGrouping[B]] = { groupArgs(flatArgs0, argSigs, allowPositional, allowRepeats, allowLeftover, _ => None) } @@ -39,20 +39,24 @@ object TokenGrouping { .toMap[String, ArgSig] lazy val shortArgMap: Map[Char, ArgSig] = argSigs - .collect{case (a, _) if !a.positional => a.shortName.map(_ -> a)} + .collect { case (a, _) if !a.positional => a.shortName.map(_ -> a) } .flatten .toMap[Char, ArgSig] lazy val shortFlagArgMap: Map[Char, ArgSig] = argSigs - .collect{case (a, r: TokensReader.Flag) if !a.positional => a.shortName.map(_ -> a)} + .collect { case (a, r: TokensReader.Flag) if !a.positional => a.shortName.map(_ -> a) } .flatten .toMap[Char, ArgSig] - lazy val longKeywordArgMap = makeKeywordArgMap(x => x.mappedName(nameMapper).map("--"+ _ ) ++ x.longName(Util.nullNameMapper).map("--" + _)) + lazy val longKeywordArgMap = makeKeywordArgMap(x => + x.mappedName(nameMapper).map("--" + _) ++ x.longName(Util.nullNameMapper).map("--" + _) + ) - def parseCombinedShortTokens(current: Map[ArgSig, Vector[String]], - head: String, - rest: List[String]) = { + def parseCombinedShortTokens( + current: Map[ArgSig, Vector[String]], + head: String, + rest: List[String] + ) = { val chars = head.drop(1) var rest2 = rest var i = 0 @@ -100,7 +104,10 @@ object TokenGrouping { if (failure) Left(incomplete) else Right((rest2, currentMap)) } - def lookupArgMap(k: String, m: Map[String, ArgSig]): Option[(ArgSig, mainargs.TokensReader[_])] = { + def lookupArgMap( + k: String, + m: Map[String, ArgSig] + ): Option[(ArgSig, mainargs.TokensReader[_])] = { m.get(k).map(a => (a, a.reader)) } @@ -111,16 +118,16 @@ object TokenGrouping { remaining match { case head :: rest => // special handling for combined short args of the style "-xvf" or "-j10" - if (head.startsWith("-") && head.lift(1).exists(c => c != '-')){ - parseCombinedShortTokens(current, head, rest) match{ - case Left(Some(incompleteArg)) => - Result.Failure.MismatchedArguments(Nil, Nil, Nil, incomplete = Some(incompleteArg)) - case Left(None) => complete(remaining, current) - case Right((rest2, currentMap)) => rec(rest2, currentMap) + if (head.startsWith("-") && head.lift(1).exists(c => c != '-')) { + parseCombinedShortTokens(current, head, rest) match { + case Left(Some(incompleteArg)) => + Result.Failure.MismatchedArguments(Nil, Nil, Nil, incomplete = Some(incompleteArg)) + case Left(None) => complete(remaining, current) + case Right((rest2, currentMap)) => rec(rest2, currentMap) } } else if (head.startsWith("-") && head.exists(_ != '-')) { - head.split("=", 2) match{ + head.split("=", 2) match { case Array(first, second) => lookupArgMap(first, longKeywordArgMap) match { case Some((cliArg, _: TokensReader.Simple[_])) => @@ -173,10 +180,10 @@ object TokenGrouping { val missing = argSigs.collect { case (a, r: TokensReader.Simple[_]) - if !r.allowEmpty - && a.default.isEmpty - && !current.contains(a) => - a + if !r.allowEmpty + && a.default.isEmpty + && !current.contains(a) => + a } val unknown = if (allowLeftover) Nil else remaining diff --git a/mainargs/src/TokensReader.scala b/mainargs/src/TokensReader.scala index 560a815..2452718 100644 --- a/mainargs/src/TokensReader.scala +++ b/mainargs/src/TokensReader.scala @@ -22,6 +22,7 @@ object TokensReader { sealed trait Terminal[T] extends TokensReader[T] sealed trait ShortNamed[T] extends Terminal[T] { + /** * The label that shows up in the CLI help message, e.g. the `bar` in * `--foo ` @@ -34,6 +35,7 @@ object TokensReader { * e.g. `--foo bar` */ trait Simple[T] extends ShortNamed[T] { + /** * Converts the given input tokens to a [[T]] or an error `String`. * The input is a `Seq` because input tokens can be passed more than once, @@ -136,7 +138,8 @@ object TokensReader { def read(strs: Seq[String]) = tryEither(BigDecimal(strs.last)) } - implicit def LeftoverRead[T: TokensReader.Simple]: TokensReader.Leftover[mainargs.Leftover[T], T] = + implicit def LeftoverRead[T: TokensReader.Simple] + : TokensReader.Leftover[mainargs.Leftover[T], T] = new LeftoverRead[T]()(implicitly[TokensReader.Simple[T]]) class LeftoverRead[T](implicit wrapped: TokensReader.Simple[T]) @@ -144,7 +147,7 @@ object TokensReader { def read(strs: Seq[String]) = { val (failures, successes) = strs .map(s => - implicitly[TokensReader[T]] match{ + implicitly[TokensReader[T]] match { case r: TokensReader.Simple[T] => r.read(Seq(s)) case r: TokensReader.Leftover[T, _] => r.read(Seq(s)) } @@ -225,8 +228,9 @@ object TokensReader { } object ArgSig { - def create[T, B](name0: String, arg: mainargs.arg, defaultOpt: Option[B => T]) - (implicit tokensReader: TokensReader[T]): ArgSig = { + def create[T, B](name0: String, arg: mainargs.arg, defaultOpt: Option[B => T])(implicit + tokensReader: TokensReader[T] + ): ArgSig = { val shortOpt = arg.short match { case '\u0000' => if (name0.length != 1 || arg.noDefaultName) None else Some(name0(0)); case c => Some(c) @@ -251,13 +255,15 @@ object ArgSig { } @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def apply(unMappedName: Option[String], - shortName: Option[Char], - doc: Option[String], - default: Option[Any => Any], - reader: TokensReader[_], - positional: Boolean, - hidden: Boolean) = { + def apply( + unMappedName: Option[String], + shortName: Option[Char], + doc: Option[String], + default: Option[Any => Any], + reader: TokensReader[_], + positional: Boolean, + hidden: Boolean + ) = { new ArgSig(unMappedName, unMappedName, shortName, doc, default, reader, positional, hidden) } @@ -273,15 +279,16 @@ object ArgSig { * (just for logging and reading, not a replacement for a `TypeTag`) and * possible a function that can compute its default value */ -class ArgSig private[mainargs] (val defaultLongName: Option[String], - val argName: Option[String], - val shortName: Option[Char], - val doc: Option[String], - val default: Option[Any => Any], - val reader: TokensReader[_], - val positional: Boolean, - val hidden: Boolean -) extends Product with Serializable with Equals{ +class ArgSig private[mainargs] ( + val defaultLongName: Option[String], + val argName: Option[String], + val shortName: Option[Char], + val doc: Option[String], + val default: Option[Any => Any], + val reader: TokensReader[_], + val positional: Boolean, + val hidden: Boolean +) extends Product with Serializable with Equals { @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") def name = defaultLongName override def canEqual(that: Any): Boolean = true @@ -293,31 +300,35 @@ class ArgSig private[mainargs] (val defaultLongName: Option[String], } @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def this(unmappedName: Option[String], - shortName: Option[Char], - doc: Option[String], - default: Option[Any => Any], - reader: TokensReader[_], - positional: Boolean, - hidden: Boolean) = { + def this( + unmappedName: Option[String], + shortName: Option[Char], + doc: Option[String], + default: Option[Any => Any], + reader: TokensReader[_], + positional: Boolean, + hidden: Boolean + ) = { this(unmappedName, unmappedName, shortName, doc, default, reader, positional, hidden) } @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def copy(unMappedName: Option[String] = this.unMappedName, - shortName: Option[Char] = this.shortName, - doc: Option[String] = this.doc, - default: Option[Any => Any] = this.default, - reader: TokensReader[_] = this.reader, - positional: Boolean = this.positional, - hidden: Boolean = this.hidden) = { + def copy( + unMappedName: Option[String] = this.unMappedName, + shortName: Option[Char] = this.shortName, + doc: Option[String] = this.doc, + default: Option[Any => Any] = this.default, + reader: TokensReader[_] = this.reader, + positional: Boolean = this.positional, + hidden: Boolean = this.hidden + ) = { ArgSig(unMappedName, shortName, doc, default, reader, positional, hidden) } @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") def productArity = 9 @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def productElement(n: Int) = n match{ + def productElement(n: Int) = n match { case 0 => defaultLongName case 1 => argName case 2 => shortName @@ -329,12 +340,12 @@ class ArgSig private[mainargs] (val defaultLongName: Option[String], } def unMappedName: Option[String] = argName.orElse(defaultLongName) - def longName(nameMapper: String => Option[String]): Option[String] = argName.orElse(mappedName(nameMapper)).orElse(defaultLongName) + def longName(nameMapper: String => Option[String]): Option[String] = + argName.orElse(mappedName(nameMapper)).orElse(defaultLongName) def mappedName(nameMapper: String => Option[String]): Option[String] = if (argName.isDefined) None else defaultLongName.flatMap(nameMapper) } - case class MethodMains[B](value: Seq[MainData[Any, B]], base: () => B) /** @@ -352,13 +363,13 @@ class MainData[T, B] private[mainargs] ( val argSigs0: Seq[ArgSig], val doc: Option[String], val invokeRaw: (B, Seq[Any]) => T -) extends Product with Serializable with Equals{ +) extends Product with Serializable with Equals { @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") def name = mainName.getOrElse(defaultName) @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") def productArity = 5 @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def productElement(n: Int) = n match{ + def productElement(n: Int) = n match { case 0 => mainName case 1 => defaultName case 2 => argSigs0 @@ -366,24 +377,35 @@ class MainData[T, B] private[mainargs] ( case 4 => invokeRaw } @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def copy(name: String = this.unmappedName, - argSigs0: Seq[ArgSig] = this.argSigs0, - doc: Option[String] = this.doc, - invokeRaw: (B, Seq[Any]) => T = this.invokeRaw) = MainData( - name, argSigs0, doc, invokeRaw + def copy( + name: String = this.unmappedName, + argSigs0: Seq[ArgSig] = this.argSigs0, + doc: Option[String] = this.doc, + invokeRaw: (B, Seq[Any]) => T = this.invokeRaw + ) = MainData( + name, + argSigs0, + doc, + invokeRaw ) @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def this(name: String, - argSigs0: Seq[ArgSig], - doc: Option[String], - invokeRaw: (B, Seq[Any]) => T) = this( - Some(name), name, argSigs0, doc, invokeRaw + def this( + name: String, + argSigs0: Seq[ArgSig], + doc: Option[String], + invokeRaw: (B, Seq[Any]) => T + ) = this( + Some(name), + name, + argSigs0, + doc, + invokeRaw ) @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") override def hashCode(): Int = MainData.unapply(this).hashCode() @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - override def equals(obj: Any): Boolean = obj match{ + override def equals(obj: Any): Boolean = obj match { case x: MainData[_, _] => MainData.unapply(x) == MainData.unapply(this) case _ => false } @@ -393,7 +415,8 @@ class MainData[T, B] private[mainargs] ( def unmappedName: String = mainName.getOrElse(defaultName) - def name(nameMapper: String => Option[String]) = mainName.orElse(mappedName(nameMapper)).getOrElse(defaultName) + def name(nameMapper: String => Option[String]) = + mainName.orElse(mappedName(nameMapper)).getOrElse(defaultName) def mappedName(nameMapper: String => Option[String]): Option[String] = if (mainName.isDefined) None else nameMapper(defaultName) @@ -402,17 +425,20 @@ class MainData[T, B] private[mainargs] ( argSigs0.iterator.flatMap[(ArgSig, TokensReader.Terminal[_])](ArgSig.flatten(_)).toVector val renderedArgSigs: Seq[ArgSig] = - flattenedArgSigs.collect{case (a, r) if !a.hidden && !r.isConstant => a} + flattenedArgSigs.collect { case (a, r) if !a.hidden && !r.isConstant => a } } object MainData { @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def unapply[T, B](x: MainData[T, B]) = Option((x.mainName, x.defaultName, x.argSigs0, x.doc, x.invokeRaw)) + def unapply[T, B](x: MainData[T, B]) = + Option((x.mainName, x.defaultName, x.argSigs0, x.doc, x.invokeRaw)) @deprecated("Binary Compatibility Shim", "mainargs 0.6.0") - def apply[T, B](name: String, - argSigs0: Seq[ArgSig], - doc: Option[String], - invokeRaw: (B, Seq[Any]) => T) = { + def apply[T, B]( + name: String, + argSigs0: Seq[ArgSig], + doc: Option[String], + invokeRaw: (B, Seq[Any]) => T + ) = { new MainData(Some(name), name, argSigs0, doc, invokeRaw) } def create[T, B]( diff --git a/mainargs/src/Util.scala b/mainargs/src/Util.scala index d4e894f..b43c9d8 100644 --- a/mainargs/src/Util.scala +++ b/mainargs/src/Util.scala @@ -21,7 +21,7 @@ object Util { var state = ' ' for (c <- s) { - if (c.isDigit){ + if (c.isDigit) { if (state == 'L' || state == 'U') chars.append(sep) chars.append(c) state = 'D' @@ -29,7 +29,7 @@ object Util { if (state == 'L' || state == 'D') chars.append(sep) chars.append(c.toLower) state = 'U' - } else if (c.isLower){ + } else if (c.isLower) { chars.append(c) state = 'L' } else { diff --git a/mainargs/test/src-jvm-2/AmmoniteTests.scala b/mainargs/test/src-jvm-2/AmmoniteTests.scala index c9ea6db..0ecba6a 100644 --- a/mainargs/test/src-jvm-2/AmmoniteTests.scala +++ b/mainargs/test/src-jvm-2/AmmoniteTests.scala @@ -31,8 +31,8 @@ object AmmoniteConfig { case class InjectedConstant() implicit object InjectedTokensReader extends TokensReader.Constant[InjectedConstant] { - def read() = Right(new InjectedConstant()) - } + def read() = Right(new InjectedConstant()) + } @main case class Core( injectedConstant: InjectedConstant, diff --git a/mainargs/test/src/Checker.scala b/mainargs/test/src/Checker.scala index a1788e6..aaa0909 100644 --- a/mainargs/test/src/Checker.scala +++ b/mainargs/test/src/Checker.scala @@ -1,6 +1,10 @@ package mainargs -class Checker[B](val parser: ParserForMethods[B], allowPositional: Boolean, nameMapper: String => Option[String] = Util.kebabCaseNameMapper) { +class Checker[B]( + val parser: ParserForMethods[B], + allowPositional: Boolean, + nameMapper: String => Option[String] = Util.kebabCaseNameMapper +) { val mains = parser.mains def parseInvoke(input: List[String]) = { parser.runRaw(input, allowPositional = allowPositional, nameMapper = nameMapper) diff --git a/mainargs/test/src/ClassWithDefaultTests.scala b/mainargs/test/src/ClassWithDefaultTests.scala index b259159..9e8562b 100644 --- a/mainargs/test/src/ClassWithDefaultTests.scala +++ b/mainargs/test/src/ClassWithDefaultTests.scala @@ -46,13 +46,13 @@ object ClassWithDefaultTests extends TestSuite { } test("nested") { - test("success"){ + test("success") { mainParser.runOrThrow(Seq("-x", "1", "-y", "2", "--bool", "true")) ==> "1 2 true" } - test("default"){ + test("default") { mainParser.runOrThrow(Seq("-x", "1", "-y", "2")) ==> "1 2 false" } - test("default2"){ + test("default2") { mainParser.runOrThrow(Seq("-x", "0")) ==> "0 1 false" } } diff --git a/mainargs/test/src/ConstantTests.scala b/mainargs/test/src/ConstantTests.scala index d5e9d0e..24fa335 100644 --- a/mainargs/test/src/ConstantTests.scala +++ b/mainargs/test/src/ConstantTests.scala @@ -5,7 +5,7 @@ object ConstantTests extends TestSuite { case class Injected() implicit def InjectedTokensReader: TokensReader.Constant[Injected] = - new TokensReader.Constant[Injected]{ + new TokensReader.Constant[Injected] { def read() = Right(new Injected()) } object Base { diff --git a/mainargs/test/src/CoreTests.scala b/mainargs/test/src/CoreTests.scala index 803e1f1..4824b2c 100644 --- a/mainargs/test/src/CoreTests.scala +++ b/mainargs/test/src/CoreTests.scala @@ -15,8 +15,7 @@ object CoreBase { i: Int, @arg(doc = "Pass in a custom `s` to override it") s: String = "lols" - ) - = s * i + ) = s * i @main def baz(arg: Int) = arg @@ -86,7 +85,7 @@ class CoreTests(allowPositional: Boolean) extends TestSuite { ) ), List( - (Some("arg"), None, None, None, TokensReader.IntRead), + (Some("arg"), None, None, None, TokensReader.IntRead) ), List() ) @@ -143,19 +142,19 @@ class CoreTests(allowPositional: Boolean) extends TestSuite { // incomplete arguments as distinct from other mismatches test - assertMatch(check.parseInvoke(List("qux", "-s"))) { case Result.Failure.MismatchedArguments( - Nil, - Nil, - Nil, - Some(_) - ) => + Nil, + Nil, + Nil, + Some(_) + ) => } test - assertMatch(check.parseInvoke(List("baz", "--arg"))) { case Result.Failure.MismatchedArguments( - Nil, - Nil, - Nil, - Some(_) - ) => + Nil, + Nil, + Nil, + Some(_) + ) => } } } @@ -250,7 +249,15 @@ object CorePositionalDisabledOnlyTests extends TestSuite { test("redundantParams") - check( List("qux", "1", "-i", "2"), MismatchedArguments( - missing = List(ArgSig(None, Some('i'), None, None, TokensReader.IntRead, positional = false, hidden = false)), + missing = List(ArgSig( + None, + Some('i'), + None, + None, + TokensReader.IntRead, + positional = false, + hidden = false + )), unknown = List("1", "-i", "2") ) ) diff --git a/mainargs/test/src/DashedArgumentName.scala b/mainargs/test/src/DashedArgumentName.scala index f21a812..03b97b2 100644 --- a/mainargs/test/src/DashedArgumentName.scala +++ b/mainargs/test/src/DashedArgumentName.scala @@ -14,10 +14,16 @@ object DashedArgumentName extends TestSuite { def camelOptFor29Name(camelOptFor29Arg: Boolean) = camelOptFor29Arg @main(name = "camelOptFor29NameForce") - def camelOptFor29NameForce(@arg(name = "camelOptFor29ArgForce") camelOptFor29ArgForce: Boolean) = camelOptFor29ArgForce + def camelOptFor29NameForce(@arg(name = + "camelOptFor29ArgForce" + ) camelOptFor29ArgForce: Boolean) = camelOptFor29ArgForce } val check = new Checker(ParserForMethods(Base), allowPositional = true) - val snakeCaseCheck = new Checker(ParserForMethods(Base), allowPositional = true, nameMapper = Util.snakeCaseNameMapper) + val snakeCaseCheck = new Checker( + ParserForMethods(Base), + allowPositional = true, + nameMapper = Util.snakeCaseNameMapper + ) val tests = Tests { test("backticked") { @@ -61,7 +67,12 @@ object DashedArgumentName extends TestSuite { test("explicitMainNameMappedFails") - check( List("camel-opt-for-29-name-force", "--camel-opt-for-29-arg-force", "false"), Result.Failure.Early.UnableToFindSubcommand( - List("opt-for-18+name", "opt-for-29+name", "camel-opt-for-29-name", "camelOptFor29NameForce"), + List( + "opt-for-18+name", + "opt-for-29+name", + "camel-opt-for-29-name", + "camelOptFor29NameForce" + ), "camel-opt-for-29-name-force" ) ) @@ -84,7 +95,6 @@ object DashedArgumentName extends TestSuite { List(), None ) - ) } test("camelSnakeNameMapped") { diff --git a/mainargs/test/src/EqualsSyntaxTests.scala b/mainargs/test/src/EqualsSyntaxTests.scala index 67311d2..bd74926 100644 --- a/mainargs/test/src/EqualsSyntaxTests.scala +++ b/mainargs/test/src/EqualsSyntaxTests.scala @@ -40,13 +40,13 @@ object EqualsSyntaxTests extends TestSuite { test("notFlags") { // -f=bar syntax doesn't work for flags ParserForMethods(Main).runEither(Array("--foo=bar", "--bool=true")) ==> - Left("""Unknown argument: "--bool=true" - |Expected Signature: run - | --bool Example flag - | -f --foo String to print repeatedly - | --my-num How many times to print string - | - |""".stripMargin) + Left("""Unknown argument: "--bool=true" + |Expected Signature: run + | --bool Example flag + | -f --foo String to print repeatedly + | --my-num How many times to print string + | + |""".stripMargin) } } } diff --git a/mainargs/test/src/FlagTests.scala b/mainargs/test/src/FlagTests.scala index 459a2ce..9f47c99 100644 --- a/mainargs/test/src/FlagTests.scala +++ b/mainargs/test/src/FlagTests.scala @@ -37,7 +37,7 @@ object FlagTests extends TestSuite { Result.Success(Seq(true, false, true)) ) - test("combined"){ + test("combined") { test - check( List("bool", "-bfalse"), Result.Success(List(false, false, false)) @@ -101,7 +101,15 @@ object FlagTests extends TestSuite { Result.Failure.InvalidArguments( List( Result.ParamError.Failed( - new ArgSig(None, Some('b'), None, None, mainargs.TokensReader.BooleanRead, false, false), + new ArgSig( + None, + Some('b'), + None, + None, + mainargs.TokensReader.BooleanRead, + false, + false + ), Vector("a"), "java.lang.IllegalArgumentException: For input string: \"a\"" ) diff --git a/mainargs/test/src/InvocationArgs.scala b/mainargs/test/src/InvocationArgs.scala index bcafec6..571a9ea 100644 --- a/mainargs/test/src/InvocationArgs.scala +++ b/mainargs/test/src/InvocationArgs.scala @@ -2,41 +2,41 @@ package mainargs import utest._ @main case class LargeArgs( - v1: String, - v2: String = "v2-default", - v3: Option[String] = None, - v4: Option[String] = None, - v5: Int, - v6: Int = 0, - v7: Int = 123, - v8: Int = 3.14.toInt, - v9: Boolean, - v10: Boolean = true, - v11: Boolean = false, - v12: Option[Int] = None, - v13: Option[Int] = None, - v14: String = "v14-default", - v15: String = "v15-default", - v16: String = "v16-default", - v17: String = "v17-default", - v18: String = "v18-default", - v19: String = "v19-default", - v20: String = "v20-default", - v21: String = "v21-default", - v22: String = "v22-default", - v23: String = "v23-default", - v24: String = "v24-default", - v25: String = "v25-default", - v26: String = "v26-default", - v27: String = "v27-default", - v28: String = "v28-default", - v29: String = "v29-default", - v30: String = "v30-default", - v31: String = "v31-default", - v32: String = "v32-default", + v1: String, + v2: String = "v2-default", + v3: Option[String] = None, + v4: Option[String] = None, + v5: Int, + v6: Int = 0, + v7: Int = 123, + v8: Int = 3.14.toInt, + v9: Boolean, + v10: Boolean = true, + v11: Boolean = false, + v12: Option[Int] = None, + v13: Option[Int] = None, + v14: String = "v14-default", + v15: String = "v15-default", + v16: String = "v16-default", + v17: String = "v17-default", + v18: String = "v18-default", + v19: String = "v19-default", + v20: String = "v20-default", + v21: String = "v21-default", + v22: String = "v22-default", + v23: String = "v23-default", + v24: String = "v24-default", + v25: String = "v25-default", + v26: String = "v26-default", + v27: String = "v27-default", + v28: String = "v28-default", + v29: String = "v29-default", + v30: String = "v30-default", + v31: String = "v31-default", + v32: String = "v32-default" ) -object LargeClassTests extends TestSuite{ +object LargeClassTests extends TestSuite { val largeArgsParser = ParserForClass[LargeArgs] val tests = Tests { diff --git a/mainargs/test/src/IssueTests.scala b/mainargs/test/src/IssueTests.scala index 2ec7b8d..eb2c434 100644 --- a/mainargs/test/src/IssueTests.scala +++ b/mainargs/test/src/IssueTests.scala @@ -5,9 +5,11 @@ object IssueTests extends TestSuite { object Main { @main - def mycmd(@arg(name = "the-flag") f: mainargs.Flag = mainargs.Flag(false), - @arg str: String = "s", - args: Leftover[String]) = { + def mycmd( + @arg(name = "the-flag") f: mainargs.Flag = mainargs.Flag(false), + @arg str: String = "s", + args: Leftover[String] + ) = { (f.value, str, args.value) } } diff --git a/mainargs/test/src/VarargsBaseTests.scala b/mainargs/test/src/VarargsBaseTests.scala index a8566ba..17aae13 100644 --- a/mainargs/test/src/VarargsBaseTests.scala +++ b/mainargs/test/src/VarargsBaseTests.scala @@ -114,7 +114,7 @@ trait VarargsBaseTests extends TestSuite { } } - test("failedCombinedShortArgsGoToLeftover"){ + test("failedCombinedShortArgsGoToLeftover") { test - check( List("mixedVariadic", "-f", "123", "abc", "xyz"), Result.Success("123abcxyz") From 6074286ab07e3bc3b4f145d2aa404ed860d9d0d9 Mon Sep 17 00:00:00 2001 From: Scala Steward Date: Sat, 12 Oct 2024 13:23:31 +0000 Subject: [PATCH 3/3] Add 'Reformat with scalafmt 3.7.17' to .git-blame-ignore-revs --- .git-blame-ignore-revs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 4d9c490..667a23a 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -4,3 +4,6 @@ f6bdd1574b34dd2f7eb6737863bff6dbb876bbb2 # Scala Steward: Reformat with scalafmt 3.7.2 306a9a501c20a74348d8640da8f2b1cb89172706 + +# Scala Steward: Reformat with scalafmt 3.7.17 +1d3a9ba3d19b8a74d6523a4d5f0c2f733cea5ed3