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

com.indix.pail.ArgsParser.scala Maven / Gradle / Ivy

There is a newer version: 2.0.21
Show newest version
package com.indix.pail

import org.apache.commons.cli.{CommandLine, Options, PosixParser}


trait ArgsParser {
  val options: Options

  def cmdArgs(name: String)(implicit cli: CommandLine) = {
    if (cli.hasOption(name)) {
      cli.getOptionValue(name)
    } else {
      throw new RuntimeException(s"$name has not been provided")
    }
  }

  def cmdOptionalArgs(name: String)(implicit cli: CommandLine) = {
    if (cli.hasOption(name)) {
      Some(cli.getOptionValue(name))
    } else {
      None
    }
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy