All Versions
11
Latest Version
Avg Release Cycle
270 days
Latest Release
1243 days ago

Changelog History
Page 1

  • v4.0.0 Changes

    November 29, 2020

    πŸ‘€ scopt is a little command line options parsing library. See https://eed3si9n.com/scopt4 for the details.

    πŸ— scopt 4.0.0 is cross published to the following build matrix:

    Scala Version JVM JS (1.x) JS (0.6.x) Native (0.4.x) Native (0.3.x)
    3.0.0-M2 βœ… βœ… n/a n/a n/a
    3.0.0-M1 βœ… βœ… n/a n/a n/a
    2.13.x βœ… βœ… βœ… n/a n/a
    2.12.x βœ… βœ… βœ… n/a n/a
    2.11.x βœ… βœ… βœ… βœ… βœ…

    Functional DSL

    scopt 4.0.0 brings a new Functional DSL.

    import scopt.OParserval builder = OParser.builder[Config]val parser1 = { import builder.\_OParser.sequence( programName("scopt"), head("scopt", "4.x"), // option -f, --foo opt[Int]('f', "foo") .action((x, c) =\> c.copy(foo = x)) .text("foo is an integer property"), // more options here... ) }// OParser.parse returns Option[Config]OParser.parse(parser1, args, Config()) match { case Some(config) =\>// do somethingcase \_ =\>// arguments are bad, error message will have been displayed}
    

    Abstracting over effects

    πŸ“œ If your application requires parsing arguments while not producing output directly, you may wish to intercept the side effects. Use OParser.runParser(...) to do so:

    // OParser.runParser returns (Option[Config], List[OEffect])OParser.runParser(parser1, args, Config()) match { case (result, effects) =\>OParser.runEffects(effects, new DefaultOEffectSetup { // override def displayToOut(msg: String): Unit = Console.out.println(msg)// override def displayToErr(msg: String): Unit = Console.err.println(msg)// override def reportError(msg: String): Unit = displayToErr("Error: " + msg)// override def reportWarning(msg: String): Unit = displayToErr("Warning: " + msg)// ignore terminateoverride def terminate(exitState: Either[String, Unit]): Unit = () }) result match { Some(config) =\>// do somethingcase \_ =\>// arguments are bad, error message will have been displayed } }
    

    πŸ“œ Object-oriented DSL, immutable parsing

    πŸ’… We kept the source-compatibility with scopt 3.x style object-oriented DSL. The following should work without modification:

    val parser = new scopt.OptionParser[Config]("scopt") { head("scopt", "4.x") opt[Int]('f', "foo") .action((x, c) =\> c.copy(foo = x)) .text("foo is an integer property") opt[File]('o', "out") .required() .valueName("\<file\>") .action((x, c) =\> c.copy(out = x)) .text("out is a required file property") }// parser.parse returns Option[C]parser.parse(args, Config()) match { case Some(config) =\>// do stuffcase None =\>// arguments are bad, error message will have been displayed}
    

    Participation

    πŸ”€ According to git shortlog -sn --no-merges v3.7.1...v4.0.0, scopt 4.0.0 is brought to you by 12 contributors. Thanks!

        28 Eugene Yokota (eed3si9n)
        12 Kenji Yoshida (xuwei-k)
         6 Christophe Vidal
         4 Morgen Peschke
         2 Sasa Zejnilovic
         1 Lorenzo Gabriele
         1 Martynas Mickevičius
         1 Sean Sullivan
         1 aappddeevv
         1 Enver Osmanov
         1 Daniel
         1 Hanns Holger Rutz
         1 Jeff Shaw
    
  • v4.0.0-RC2 Changes

    December 27, 2018
  • v4.0.0-RC1

    December 27, 2018
  • v3.7.1 Changes

    December 13, 2018

    scopt 3.7.1 is cross built for Scala 2.10, 2.11, 2.12, 2.13.0, (2.13.0-M5), JS 0.6, and Native 0.3.

    • scopt 3.7.1 is built using JDK 8.
    • πŸ›  Fixes hidden commands are displayed in usage #203 by @ozeebee
    • βž• Adds typeclass instance for parsing URL #206 by @aaabramov
    • βž• Adds overload for version and help with long and short options #213 by @dani909
    • ⚑️ Other build updates from @xuwei-k, @SethTisue, and @ashawley

    v3.7.0...v3.7.1

        20 Kenji Yoshida (xuwei-k)
         6 Eugene Yokota
         1 Dale Wijnand
         1 Denys Shabalin
         1 Aaron S. Hawley
         1 Seth Tisue
         1 dani09
         1 ozeebee
         1 Brett Randall
         1 Andrii Abramov
    
  • v3.7.0 Changes

    August 25, 2017

    scopt 3.7.0 is cross built for Scala 2.10, 2.11, 2.12, 2.13.0-M2, JS 0.6, and Native 0.3.

    withFallback

    πŸ‘ Options now support a fallback value.

    val parser = new scopt.OptionParser[Unit]("scopt") { head("scopt", "3.x") opt[String]("stringValue").required().withFallback(() =\> "someFallback") .foreach( x =\> stringValue = x ) help("help") }
    

    This feature was contributed by @mpollmeier in #150

    more exposure

    πŸ”¦ Exposes values and methods such name, getMinOccurs, getMaxOccurs, isHidden, desc, shortOpt, and valueName. #138 by @rhpvorderman

  • v3.6.0 Changes

    June 02, 2017

    v3.5.0...v3.6.0

    πŸ‘ Scala.js support

    πŸ‘ Scala.js support was added by @aappddeevv in #137.

    Scala Native

    πŸ‘ Scala Native support was added by @Duhemm in #141

    πŸ› bug fixes and minor enhancements

    • βž• Adds opt[Char] support (typeclass instance Read[Char]). #130 by @emanresusername
    • πŸ–¨ Prints usage even if there are no options. #131 by @remus32
    • πŸ›  Fixes infinite loop when a subcommand is hidden. #133 by @tksfz
    • βž• Adds better support for capturing output. #139 by @gzoller
  • v3.5.0 Changes

    June 12, 2016

    πŸ’₯ breaking changes

    two-column rendering

    0️⃣ scopt 3.5.0 introduces two-column rendering for the usage text, which is enabled by default:

    scopt 3.x
    Usage: scopt [update] [options] [<file>...]
    
      -f, --foo <value> foo is an integer property
      -o, --out <file> out is a required file property
    
    Command: update [options]
    update is a command.
      --xyz <value> xyz is a boolean property
    

    This is a bit more compact compared to the previous (one-column) rendering that looked like this:

    scopt 3.x
    Usage: scopt [update] [options] [<file>...]
    
      -f <value> | --foo <value>
            foo is an integer property
      -o <file> | --out <file>
            out is a required file property
    
    Command: update [options]
    update is a command.
      --xyz <value>
            xyz is a boolean property
    

    You can switch back to the one-column rendering as follows:

    override def renderingMode = scopt.RenderingMode.OneColumn
    

    This feature was contributed by @Jibbers42 as #109.

  • v3.4.0 Changes

    June 12, 2016

    πŸ‘Œ support for optional equal sign

    πŸ“œ Given a parser like this:

    val intParser1 = new scopt.OptionParser[Config]("scopt") {
      head("scopt", "3.x")
      opt[Int]('f', "foo") action { (x, c) => c.copy(intValue = x) }
      help("help")
    }
    

    scopt 3.4.0 accepts all of the following options:

    • --foo 1
    • --foo:1
    • --foo=1

    This was contributed as #87 by @maizy.

    terminate

    scopt 3.4.0 adds a termination hanlder called terminate(exitState: Either[String, Unit]). Override this method to prevent scopt from calling sys.exit(0) on --help or --version.

    This was contributed as #74 by @metasim.

    πŸ›  other minor fixes and enhancements

    • βž• Adds Read[Seq[(K,V)]], which parses key=1,key=2 as List("key" -> "1","key" -> "2"). #70 by @sonenko
    • βž• Adds Read[InetAddress], which parses an IP address using java.net.InetAddress.getByName. #79 by @alexanderfefelov
    • βž• Adds Read[Duration], which parses 30s as Duration("30s"). #86 by @serejja
    • Increases the limit of unbounded() args. #83 by @billonahill
    • πŸ‘ Scala 2.9.x support is dropped.
  • v3.3.0 Changes

    June 12, 2016

    comma-separated values

    πŸ‘ scopt 3.3.0 adds support for comma-separated values that map to Seq[A] and Map[K, V] (where A, K and V are instance of Read).

    • A Seq[File] accepts a string containing comma-separated values such as --jars foo.jar,bar.jar
    • A Map[String, String] accepts a string containing comma-separated pairs like --kwargs key1=val1,key2=val2

    Here's how they can be used:

    opt[Seq[File]]('j', "jars") valueName("<jar1>,<jar2>...") action { (x,c) =>
      c.copy(jars = x) } text("jars to include")
    opt[Map[String,String]]("kwargs") valueName("k1=v1,k2=v2...") action { (x, c) =>
      c.copy(kwargs = x) } text("other arguments")
    

    #56 by @melrief.

  • v3.2.0 Changes

    June 12, 2016

    πŸ’₯ breaking changes

    shorter error message

    πŸ–¨ Instead of printing a wall of usage text on error, if help("help") option is defined, scopt 3.2.0 prints just the error message and suggests to "Try --help for more information."
    βͺ This behavior can be reverted by overriding showUsageOnError.

    #22 requested by @tksk.

    πŸ–¨ usage text prints to Console.out

    πŸ–¨ Usage text will print to Console.out instead of Console.err when invoked as --help. #24 reported by @Ceilican.

    πŸ†• new features

    hidden options

    opt can now be hidden().

    opt[Unit]("debug") hidden() action { (_, c) =>
      c.copy(debug = true) } text("this option is hidden in the usage text")
    

    #21 contributed by @tksk.

    πŸ”§ check configuration

    To check consistency among the provided opt values, scopt 3.2.0 introduces checkConfig.

    val parser = new scopt.OptionParser[Config]("scopt") {
      head("scopt", "3.x")
      opt[Unit]('k', "keepalive") action { (x, c) =>
        c.copy(keepalive= true) }
      opt[Boolean]("xyz") action { (x, c) =>
        c.copy(xyz = x) } text("xyz is a boolean property"),
      checkConfig { c =>
        if (c.keepalive && c.xyz) failure("xyz cannot keep alive") else success }
      help("help") text("prints this usage text")
    }
    

    #27 requested by @zero-sum.