'scala main method called twice

The main method is being called twice hence getting print and asking command line input twice

object Controller {
  def main(args: Array[String]): Unit = {
    println()
    var path=""
    if (args!=null) {
      for(arg<-args) {
        if (arg.contains("path")) {
          path = arg.substring(5)
          println(path)
          println("Please enter the string to search ")
          val inStr=scala.io.StdIn.readLine()
          println("String entered is "+inStr+"\n")
        }
      }
    } else {
      println()
      println("agrs was null")
    }
  }
}

Created jar and executed with command

scala simplesearch_2.13-0.1.0-SNAPSHOT.jar path=Alpha

Output Output

All args println



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source