def infoCmd()

in db/flyway.sc [27:63]


def infoCmd(env: String, flyway: Flyway): Unit = {

  val table: Table = (flyway
    .info()
    .all()
    .toList
    .map(info =>
      List(
        info.getVersion().getVersion(),
        info.getDescription(),
        Try(info.getInstalledOn().toString()).getOrElse(""),
        Try(info.getState().toString()).getOrElse("")
      )
    ))

  tabulate(List("version", "description", "installed on", "state"), table)

  def tabulate(headers: Row, t: Table) = {
    val widths = (headers +: t).transpose.map(_.map(_.length).max)
    val totalWidth = widths.sum + widths.size * 3 - 1

    def pad(cols: List[String]) =
      cols.zipWithIndex.map(pair => pair._1.padTo(widths(pair._2), ' '))

    println("+" + "-" * totalWidth + "+")

    println(pad(headers).mkString("| ", " | ", " |"))

    println("+" + "-" * totalWidth + "+")

    for (row <- t) {
      println(pad(row).mkString("| ", " | ", " |"))
    }

    println("+" + "-" * totalWidth + "+")
  }
}