def app()

in src/main/scala/com/adamnfish/eek/Main.scala [37:78]


  def app(appComponents: AppComponents[IO]): IO[ExitCode] = {
    given LoggerFactory[IO] = Slf4jFactory.create[IO]
    val logger = LoggerFactory.getLogger[IO]

    val program = for {
      // lookup all the documentation files we'll be evaluating
      docs <- appComponents.sourceCode.repoDocs
      _ <- appComponents.printer.println(
        s"Evaluated docs files: ${docs.map(df => s"${CYAN}${df.path}${RESET}").mkString(", ")}"
      )
      // send the documentation files to our LLM for evaluation
      (docsEvaluation, thoughts) <- appComponents.docsEvaluator.evaluateDocs(
        docs
      )
      // print the evaluator's thought process in verbose mode
      _ <-
        if (appComponents.appFlags.verbose)
          appComponents.printer.println(
            DocsEvaluation
              .formatThoughts(thoughts, appComponents.printer.formatter)
          )
        else IO.unit
      // print the evaluation result
      _ <- appComponents.printer.println(
        formatDocsEvaluation(
          appComponents.sourceCode.summary,
          docsEvaluation,
          appComponents.printer.formatter
        )
      )
    } yield ExitCode.Success
    // if we hit any errors, print a message and log the details
    program.recoverWith { case NonFatal(err) =>
      for {
        _ <- logger.error(err)("Unhandled exception")
        _ <- IO.consoleForIO.errorln(
          "Unexpected error - check logs for full details"
        )
        _ <- IO.consoleForIO.errorln(err.getMessage)
      } yield ExitCode.Error
    }
  }