scala-commandline


License

License

Categories

Categories

Scala Languages
GroupId

GroupId

de.lolhens
ArtifactId

ArtifactId

scala-commandline_2.13
Last Version

Last Version

0.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

scala-commandline
scala-commandline
Project URL

Project URL

https://github.com/LolHens/scala-commandline
Project Organization

Project Organization

de.lolhens
Source Code Management

Source Code Management

https://github.com/LolHens/scala-commandline

Download scala-commandline_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/de.lolhens/scala-commandline_2.13/ -->
<dependency>
    <groupId>de.lolhens</groupId>
    <artifactId>scala-commandline_2.13</artifactId>
    <version>0.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/de.lolhens/scala-commandline_2.13/
implementation 'de.lolhens:scala-commandline_2.13:0.3.1'
// https://jarcasting.com/artifacts/de.lolhens/scala-commandline_2.13/
implementation ("de.lolhens:scala-commandline_2.13:0.3.1")
'de.lolhens:scala-commandline_2.13:jar:0.3.1'
<dependency org="de.lolhens" name="scala-commandline_2.13" rev="0.3.1">
  <artifact name="scala-commandline_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='de.lolhens', module='scala-commandline_2.13', version='0.3.1')
)
libraryDependencies += "de.lolhens" % "scala-commandline_2.13" % "0.3.1"
[de.lolhens/scala-commandline_2.13 "0.3.1"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.3
org.typelevel : cats-core_2.13 jar 2.2.0

Project Modules

There are no modules declared in this project.

scala-commandline

Test Workflow Release Notes Maven Central Apache License 2.0

A small state-monad-based command line parser library written in scala.

build.sbt

libraryDependencies += "de.lolhens" %% "scala-commandline" % "0.3.1"

Example

case class Options(help: Boolean,
                   version: Boolean,
                   logLevel: Option[String],
                   decode: Boolean,
                   validate: Boolean,
                   params: Seq[String])

def main(args: Array[String]): Unit = {
  val options: Options = CommandLine(args) {
    for {
      default <- CommandLine.defaultOpts()
      /* shorthand for:
      empty <- CommandLine.isEmpty
      help <- CommandLine.opt("-h", "--help").flag
      version <- CommandLine.opt("--version").flag
      */
      logLevel <- CommandLine.opt("--loglevel").arg.map(_.lastOption)
      decode <- CommandLine.opt("-d", "--decode").flag
      validate <- CommandLine.opt("--validate").flag
      _ <- CommandLine.errorOnUnrecognizedOpts()
      params <- CommandLine.args
    } yield Options(
      help = default.empty || default.help,
      version = default.version,
      logLevel = logLevel,
      decode = decode,
      validate = validate,
      params = params
    )
  }
}

License

This project uses the Apache 2.0 License. See the file called LICENSE.

Versions

Version
0.3.1
0.3.0
0.2.1
0.2.0
0.1.0
0.0.1