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

abellectl_2.12.1.0.0-RC3.source-code.Report.scala Maven / Gradle / Ivy

There is a newer version: 1.1.0-RC3
Show newest version
package info.hupel.isabelle.cli

import scala.concurrent._

import info.hupel.isabelle._
import info.hupel.isabelle.api._

object Report extends Command {

  sealed abstract class Format
  case object Dump extends Format
  case object RawXML extends Format
  case object Model extends Format
  case object XRay extends Format

  def print(trees: List[XML.Tree], env: Environment, format: Format): Unit = format match {
    case RawXML =>
      println(s"\n\n")
      Reports.fromTrees(trees).items.foreach(tree => println(tree.pretty(2)))
      println("\n")
    case Dump =>
      println(s"\n\n")
      trees.foreach(tree => println(tree.pretty(2)))
      println("\n")
    case Model =>
      val model = Reports.fromTrees(trees).interpret(env)

      println(model.pretty)
    case XRay =>
      val model = Reports.fromTrees(trees).interpret(env)

      println("")
      println(model.toHTML)
  }

  override def run(bundle: Bundle, args: List[String])(implicit ec: ExecutionContext): Future[Unit] = {
    val (format, files) = args match {
      case "--format" :: "raw-xml" :: files => (RawXML, files)
      case "--format" :: "model" :: files => (Model, files)
      case "--format" :: "x-ray" :: files => (XRay, files)
      case "--format" :: "dump" :: files => (Dump, files)
      case "--format" :: _ => sys.error("unknown format")
      case _ => (RawXML, args)
    }

    for {
      s <- System.create(bundle.env, bundle.configuration)
      r <- s.invoke(Operation.UseThys(List.empty[XML.Tree])((trees, tree) => tree :: trees, _.reverse))(files)
      _ <- s.dispose
    }
    yield print(r.unsafeGet, bundle.env, format)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy