All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.iheart.thomas.cli.Main.scala Maven / Gradle / Ivy

The newest version!
package com.iheart.thomas
package cli

import com.monovore.decline.{Command, Opts}
import cats.effect.{ExitCode, IO, IOApp}

object Main extends IOApp {
  def run(args: List[String]): IO[ExitCode] = {
    val cmd: Command[IO[String]] = Command("thomas", "Thomas cli")(
      Opts.subcommands(
        new GroupMetaCommands[IO].groupMetaCommand,
        new EligibilityControlCommand[IO].userMetaCriteriaCommand
      )
    )

    IO(
      System.out.print(
        util.Random
          .shuffle(logos)
          .head + s"\n${BuildInfo.name} v${BuildInfo.version}\n\n"
      )
    ) *>
      cmd
        .parse(args)
        .fold(
          help => IO(println(help)).as(ExitCode.Error),
          _.flatMap(r => IO(println(r))).as(ExitCode.Success).onError { case e =>
            IO(println(s"""
                |$errorSign
                |!!!!!!!!!!!!!!!!!!!!!!!!!!!ERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                |
                |$e
                |
                |!!!!!!!!!!!!!!!!!!!!!!!!!!!ERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                |""".stripMargin))
          }
        )
  }

  val logos = Seq(
    """
      |    .....                                                                     .x+=:.
      | .H8888888h.  ~-.    .uef^"                                                  z`    ^%
      | 888888888888x  `> :d88E              u.      ..    .     :                     .      X888  888X '888>  .@88 "8888" x88:  `)8b.
      |      488888>       888E  888E  888R I888>   X888  888X '888>  9888  9888  8888N=*8888
      |    .. `"88*        888E  888E  888R I888>   X888  888X '888>  9888  9888   %8"    R88
      |  x88888nX"      .  888E  888E u8888cJ888    X888  888X '888>  9888  9888    @8Wou 9%
      | !"*8888888n..  :   888E  888E  "*888*P"    "*88%""*88" '888!` 9888  9888  .888888P`
      |'    "*88888888*   m888N= 888>    'Y"         `~    "    `"`   "888*""888" `   ^"F
      |        ^"***"`     `Y"   888                                   ^Y"   ^Y'
      |                         J88"
      |                         @%
      |                       :"
    """.stripMargin,
    """
      t  _____    _
      t |_   _|  | |_       ___     _ __     __ _      ___
      t   | |    | ' \     / _ \   | '  \   / _` |    (_-<
      t  _|_|_   |_||_|    \___/   |_|_|_|  \__,_|    /__/_
      t_|'''''| _|'''''| _|'''''| _|'''''| _|'''''| _|'''''|
      t"`-0-0-' "`-0-0-' "`-0-0-' "`-0-0-' "`-0-0-' "`-0-0-'
      t
    """.stripMargin('t')
  )

  val errorSign =
    """
      |
      |████████ ██   ██ ██ ███████     ██ ███████      █████  ██     ██ ██   ██ ██     ██  █████  ██████  ██████ 
      |   ██    ██   ██ ██ ██          ██ ██          ██   ██ ██     ██ ██  ██  ██     ██ ██   ██ ██   ██ ██   ██ 
      |   ██    ███████ ██ ███████     ██ ███████     ███████ ██  █  ██ █████   ██  █  ██ ███████ ██████  ██   ██ 
      |   ██    ██   ██ ██      ██     ██      ██     ██   ██ ██ ███ ██ ██  ██  ██ ███ ██ ██   ██ ██   ██ ██   ██ 
      |   ██    ██   ██ ██ ███████     ██ ███████     ██   ██  ███ ███  ██   ██  ███ ███  ██   ██ ██   ██ ██████ 
      |
      |""".stripMargin
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy