From 03c7b478aa1ad7e24641de74ddbe700457fa9ad3 Mon Sep 17 00:00:00 2001 From: Mark Rudolph Date: Sun, 15 Dec 2024 23:06:01 -0500 Subject: [PATCH] remove printlns that would be confusing to a user --- .../wishingtree/branch/ursula/UrsulaApp.scala | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/branch/src/main/scala/dev/wishingtree/branch/ursula/UrsulaApp.scala b/branch/src/main/scala/dev/wishingtree/branch/ursula/UrsulaApp.scala index 6073a37..68738c4 100644 --- a/branch/src/main/scala/dev/wishingtree/branch/ursula/UrsulaApp.scala +++ b/branch/src/main/scala/dev/wishingtree/branch/ursula/UrsulaApp.scala @@ -7,7 +7,7 @@ import scala.util.* trait UrsulaApp { - /** This setting determines whether the built in HelpCommand is the default + /** This setting determines whether the built-in HelpCommand is the default * command. Defaults true, override to false if you want to use a different * Command as default. */ @@ -30,12 +30,6 @@ trait UrsulaApp { /** A map of trigger -> Command for quick lookup */ private lazy val commandMap: Map[String, Command] = _allCommands.groupBy(_.trigger).map { case (k, v) => - if v.size > 1 then { - println( - s"Multiple commands injected with the same trigger - using first found:" - ) - v.foreach(c => println(c.getClass.getSimpleName)) - } k -> v.head } @@ -46,33 +40,25 @@ trait UrsulaApp { /** The default command to run if no trigger is found */ private lazy val findDefaultCommand: Option[Command] = { val default = _allCommands.filter(_.isDefaultCommand) - if default.size > 1 then { - println( - "Multiple commands injected with isDefaultCommand=true - using the first:" - ) - default.foreach(c => println(c.getClass.getSimpleName)) - } default.headOption } - @volatile - private var dropOne = true + private var dropOne = true final def main(args: Array[String]): Unit = { val lzyApp = for { - cmd <- Lazy - .fromOption(args.headOption) - .map(commandMap.get) - .recover { case _: NoSuchElementException => - dropOne = false - Lazy.fn(findDefaultCommand) - } - .someOrFail( - new IllegalArgumentException( - "Could not find command from argument, and no default command provided" - ) - ) - + cmd <- Lazy + .fromOption(args.headOption) + .map(commandMap.get) + .recover { case _: NoSuchElementException => + dropOne = false + Lazy.fn(findDefaultCommand) + } + .someOrFail( + new IllegalArgumentException( + "Could not find command from argument, and no default command provided" + ) + ) result <- cmd.lazyAction(if dropOne then args.drop(1) else args) } yield result