Packages

  • package root
    Definition Classes
    root
  • package de
    Definition Classes
    root
  • package h2b
    Definition Classes
    de
  • package scala
    Definition Classes
    h2b
  • package lib
    Definition Classes
    scala
  • package util

    This is a Scala library of programming utilities.

    This is a Scala library of programming utilities. It is not intended to comprise a systematic collection but contains some tools that may be useful for some applications.

    Some highlights are a number of probability distributions, a command-line interface, a configuration package, an RSS utility, a class to handle temporary directories, control structures, a logger trait and a timer.

    Definition Classes
    lib
  • package cli

    Define the parameters of your command line as instances of

    Define the parameters of your command line as instances of

    - FlagParameter: no specific value, just signals that it is there,

    - HelpParameter: signals that the user needs some help (if given as a command-line argument, other parameters are not computed and no parse exceptions are thrown),

    - ValueParameter[V]: has exactly one value of type V,

    - ListParameter[V]: has a number of values of type V and

    - MainParameter: has a number of String values.

    ValueParameter[V] and ListParameter[V] need a converter to convert a string to the value type V. You might want to import the object Converter that provides converters for standard data types implicitly by:

    import de.h2b.scala.lib.util.cli.Converter._

    Then create a new instance of CommandLine with a set of parameters. The resulting object then can parse a string sequence or an array of strings for parameters and their values. If something goes wrong, either a ParameterException (some argument does not obey to the format specified by its parameter) or a CommandLineException (something is wrong with the arguments as a whole) is thrown.

    Finally query the original parameter instances for its value or values field.

    The usage method of CommandLine constructs a string suitable for a usage message.

    Definition Classes
    util
    Example:
    1. import de.h2b.scala.lib.util.cli._
      import de.h2b.scala.lib.util.cli.Converter._
      val overwrite = FlagParameter(Set("-o", "--overwrite"), "overwrite target")
      val mode = ValueParameter(Set("-m"), "mode", default=Some(0))
      val main = MainParameter("source target", arity=2)
      CommandLine(Set(overwrite, mode, main)).parse("-o -m 1 from to".split(' '))
      println(overwrite.value) //> Some(true)
      println(mode.value) //> Some(1)
      println(main.values) //> Some(WrappedArray(from, to))
  • CommandLine
  • CommandLineException
  • Converter
  • FlagParameter
  • HelpParameter
  • ListParameter
  • MainParameter
  • MultipleValues
  • Parameter
  • ParameterException
  • SingleValue
  • ValueParameter

case class MainParameter(description: String, arity: Int, required: Boolean = false, defaults: Option[Seq[String]] = None) extends Parameter[String] with MultipleValues[String] with Product with Serializable

A main parameter has a number of values specified by its arity.

The values can be retrieved as a sequence by the values option.

A main parameter is different from a list parameter by the absence of a name in the command line. There is, however, an internal name (MainParameter.internalName) that can be used in the command line to avoid ambiguities.

Main-parameter values can be given at the beginning or at the end of the arguments sequence (or both mixed up, but that may be confusing). Beware, that values at the end might be consumed by a variable-arity parameter in a position right before.

Linear Supertypes
Serializable, Product, Equals, MultipleValues[String], Parameter[String], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MainParameter
  2. Serializable
  3. Product
  4. Equals
  5. MultipleValues
  6. Parameter
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new MainParameter(description: String, arity: Int, required: Boolean = false, defaults: Option[Seq[String]] = None)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val arity: Int

    Specification of values following this parameter name:

    Specification of values following this parameter name:

    - positive number: exactly this number of values must follow this parameter name

    - negative number: at least abs(this number) of values must follow this parameter name (variable arity)

    - zero: no values must follow this parameter name

    Values following this parameter name will be consumed up to the next parameter.

    Definition Classes
    MainParameterParameter
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  7. val defaults: Option[Seq[String]]
    Definition Classes
    MainParameterMultipleValues
  8. val description: String
    Definition Classes
    MainParameterParameter
  9. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. val hidden: Boolean
    Definition Classes
    Parameter
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. val names: Set[String]
    Definition Classes
    MainParameterParameter
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  17. def productElementNames: Iterator[String]
    Definition Classes
    Product
  18. val required: Boolean
    Definition Classes
    MainParameterParameter
  19. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  20. def usage(namesColWidth: Int = 0): String

    A usage message of this parameter in a two-column layout.

    A usage message of this parameter in a two-column layout.

    The first column shows the names in one line, the second column shows one ore more lines of description. The lines of the description are taken as given, no automatic word wrap is done.

    namesColWidth

    minimum width of the names column (defaults to 0)

    returns

    the usage message

    Definition Classes
    Parameter
  21. def values: Option[Seq[String]]
    Definition Classes
    MultipleValues
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated @deprecated
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from MultipleValues[String]

Inherited from Parameter[String]

Inherited from AnyRef

Inherited from Any

Ungrouped