Package

scopt

Permalink

package scopt

Visibility
  1. Public
  2. All

Type Members

  1. abstract class DefaultOParserSetup extends OParserSetup

    Permalink
  2. class OParser[A, C] extends AnyRef

    Permalink

    A monadic commandline options parser.

  3. abstract class OParserBuilder[C] extends AnyRef

    Permalink
  4. trait OParserSetup extends AnyRef

    Permalink
  5. class OptionDef[A, C] extends AnyRef

    Permalink
  6. abstract class OptionDefCallback[C] extends AnyRef

    Permalink
  7. abstract class OptionParser[C] extends OptionDefCallback[C]

    Permalink

    scopt.immutable.OptionParser is instantiated within your object, set up by an (ordered) sequence of invocations of the various builder methods such as opt method or arg method.

    scopt.immutable.OptionParser is instantiated within your object, set up by an (ordered) sequence of invocations of the various builder methods such as opt method or arg method.

    val parser = new scopt.OptionParser[Config]("scopt") {
      head("scopt", "3.x")
    
      opt[Int]('f', "foo").action( (x, c) =>
        c.copy(foo = x) ).text("foo is an integer property")
    
      opt[File]('o', "out").required().valueName("").
        action( (x, c) => c.copy(out = x) ).
        text("out is a required file property")
    
      opt[(String, Int)]("max").action({
          case ((k, v), c) => c.copy(libName = k, maxCount = v) }).
        validate( x =>
          if (x._2 > 0) success
          else failure("Value  must be >0") ).
        keyValueName("", "").
        text("maximum count for ")
    
      opt[Seq[File]]('j', "jars").valueName(",...").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")
    
      opt[Unit]("verbose").action( (_, c) =>
        c.copy(verbose = true) ).text("verbose is a flag")
    
      opt[Unit]("debug").hidden().action( (_, c) =>
        c.copy(debug = true) ).text("this option is hidden in the usage text")
    
      help("help").text("prints this usage text")
    
      arg[File]("...").unbounded().optional().action( (x, c) =>
        c.copy(files = c.files :+ x) ).text("optional unbounded args")
    
      note("some notes.".newline)
    
      cmd("update").action( (_, c) => c.copy(mode = "update") ).
        text("update is a command.").
        children(
          opt[Unit]("not-keepalive").abbr("nk").action( (_, c) =>
            c.copy(keepalive = false) ).text("disable keepalive"),
          opt[Boolean]("xyz").action( (x, c) =>
            c.copy(xyz = x) ).text("xyz is a boolean property"),
          opt[Unit]("debug-update").hidden().action( (_, c) =>
            c.copy(debug = true) ).text("this option is hidden in the usage text"),
          checkConfig( c =>
            if (c.keepalive && c.xyz) failure("xyz cannot keep alive")
            else success )
        )
    }
    
    // parser.parse returns Option[C]
    parser.parse(args, Config()) match {
      case Some(config) =>
        // do stuff
    
      case None =>
        // arguments are bad, error message will have been displayed
    }
  8. class ParseException extends Exception

    Permalink
  9. trait Read[A] extends AnyRef

    Permalink
  10. trait RenderingMode extends AnyRef

    Permalink
  11. trait Zero[A] extends AnyRef

    Permalink

Value Members

  1. object OParser

    Permalink
  2. object OS extends Object

    Permalink
    Annotations
    @native() @JSImport( "os" , JSImport.Namespace )
  3. object OptionDefCallback

    Permalink
  4. object Read extends PlatformReadInstances

    Permalink
  5. object RenderingMode

    Permalink
  6. object Validation

    Permalink
  7. object Zero

    Permalink

Ungrouped