LTLCLI.scala 1.1 KB
Newer Older
1
package de.tum.niwo
Christian Müller's avatar
Christian Müller committed
2 3 4 5 6

import scala.io.Source
import com.typesafe.scalalogging.LazyLogging
import java.io.File

7 8
import de.tum.niwo.parser.WorkflowParser

Christian Müller's avatar
Christian Müller committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
object LTLCLI extends App with LazyLogging {

  lazy val usage = """
    Usage niwo-ltl.jar [--stubborn] FILE

    FILE should be a path to a Workflow Description File.
    If --stubborn is given, all agents are assumed to be stubborn, regardless of the workflow specification.
  """

  if (args.length == 0) {
    logger.info(usage)
  } else {

    var stubborn = false
    args.collect {
      case "--stubborn" => stubborn = true
    }
    val file = args.last

    logger.info(s"Using $file")

    val source = Source.fromFile(file).mkString
    val spec = WorkflowParser.parseSpec(source)
    if (!spec.successful) {
      logger.error(s"Parsing of $file unsuccessful: $spec")
      None
    } else {
      if (!spec.get.checkSanity()) {
        logger.error(s"Sanity check of $file failed. Skipping file.")
        None
      } else {
        Some(spec.get)
      }
    }

    spec.map(MainLTL.generate(new File(file).getName.stripSuffix(".spec"), _, stubborn))
  }
}