package cromwell

object CromwellApp extends App {

  sealed trait Command
  case object Run extends Command
  case object Server extends Command
  case object Submit extends Command
  
  def buildParser(): scopt.OptionParser[CommandLineArguments] = new CommandLineParser()

  def runCromwell(args: CommandLineArguments): Unit = {
    args.command match {
      case Some(Run) => CromwellEntryPoint.runSingle(args)
      case Some(Server) => CromwellEntryPoint.runServer()
      case Some(Submit) => CromwellEntryPoint.submitToServer(args)
      case None => parser.showUsage()
    }
  }

  val parser = buildParser()

  val parsedArgs = parser.parse(args, CommandLineArguments())
  parsedArgs match {
    case Some(pa) => runCromwell(pa)
    case None => parser.showUsage()
  }
}

package cromwell

object CromwellApp extends App {

  sealed trait Command
  case object Run extends Command
  case object Server extends Command
  case object Submit extends Command
  
  def buildParser(): scopt.OptionParser[CommandLineArguments] = new CommandLineParser()

  def runCromwell(args: CommandLineArguments): Unit = {
    args.command match {
      case Some(Run) => CromwellEntryPoint.runSingle(args)
      case Some(Server) => CromwellEntryPoint.runServer()
      case Some(Submit) => CromwellEntryPoint.submitToServer(args)
      case None => showUsageAndExitWithError()
    }
  }

  val parser = buildParser()

  val parsedArgs = parser.parse(args, CommandLineArguments())
  parsedArgs match {
    case Some(pa) => runCromwell(pa)
    case None => showUsageAndExitWithError()
  }

  private def showUsageAndExitWithError(): Unit = {
    parser.showUsage()
    System.exit(1)
  }
}

Exit with code "1" on malformed CLI invocation
Exit with code "1" on malformed CLI invocation [BA-3094]
