A simple library to parse command lines with batteries included
This library was developed in B2W to help creating ETL jobs in apache spark, but can be used in any kind Scala/JVM application.
AS an ELT tool, there is already a source and an output command lines. For example, for a source file names sourceFile.csv and an output file names outputFile.csv you may just:
<application> --source souceFile.csv --output outputFile.csv
or, using shortcuts
<application> -s souceFile.csv -o outputFile.csvYou may already use any (key -> value) with the --conf parameter (or it alias -c)
<application> -c filename=filename.csv -c max_node_count=3 -c "text=A value with whitespaces"Code usage is simple, you just need to create an instance of BaseParser
import com.b2wdigital.iafront.clparser.BaseParser
object Application extends App {
val appName = "Application name displayed"
val parameters = new BaseParser(args, appName)
println(parameters.sourcePathOption) // An option with --source or -s value
println(parameters.outputPathOption) // An option with --output or -o value
println(parameters.confs) // A dictionary with all --conf or -c conf key=values where key is in dictionary keys and values in dictionary values.
}If you whith to build it, you should publish locally before use in any project. In simple-command-line-parser folder run:
sbt publishLocalThen, import in your project build.sbt file
libraryDependencies ++= Seq(
"com.b2wdigital.iafront" %% "simple-command-line-parser" % "1.1-SNAPSHOT"
)The project is based on Argot, but it's abandoned. To keep it maintainable, next step is migrate to another parser tool.