Class

com.audienceproject.util.cli

Arguments

Related Doc: package cli

Permalink

class Arguments extends AnyRef

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Arguments
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Arguments()(implicit args: Array[String])

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. val arguments: Map[String, Option[String]]

    Permalink
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. def get(key: String): String

    Permalink

    Get the actual String value of an argument.

    Get the actual String value of an argument. This is useful when you need to process an argument passed as --aSetting someValue, Throws IllegalArgumentException if the key does not exist.

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--aSetting", "someValue")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
            // Returns Option[String] = Some(someValue)
            arguments.getOption("aSetting")
        }
    
    }
    key

    The argument key

  11. def getArray(key: String): Seq[String]

    Permalink

    Get a list of String for a single CLI argument.

    Get a list of String for a single CLI argument. Comma , is used as a separator character. This is useful when you need to process an arguments passed as --severalValues one,two,three. Throws IllegalArgumentException if the key does not exist.

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--severalValues", "one,two,three")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
            // Returns Option[Seq[String]] = Some(WrappedArray(one, two, three))
            arguments.getOptionArray("severalValues")
        }
    }
    key

    The argument key

  12. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  13. def getOption(key: String): Option[String]

    Permalink

    Get the String value of an argument.

    Get the String value of an argument. This is useful when you need to process an argument passed as --aSetting someValue, Returns None if the key does not exist.

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--aSetting", "someValue")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
            // Returns Option[String] = Some(someValue)
            arguments.getOption("aSetting")
        }
    
    }
    key

    The argument key

  14. def getOption(key: String, default: String): String

    Permalink

    Get the String value of an argument, or a user-provided String in case the argument does not exist.

    Get the String value of an argument, or a user-provided String in case the argument does not exist. This is useful when you need to process an argument passed as --aSetting someValue.

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--aSetting", "someValue")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
            // Returns String = "backup"
            arguments.getOption("noSetting", "backup")
        }
    
    }
    key

    The argument key

  15. def getOptionArray(key: String, default: Seq[String]): Seq[String]

    Permalink

    Get a list of String for a single CLI argument, or a default user-provided list in case the argument does not exist.

    Get a list of String for a single CLI argument, or a default user-provided list in case the argument does not exist. Comma , is used as a separator character. This is useful when you need to process an arguments passed as --severalValues one,two,three,

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--severalValues", "one,two,three")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
            // Returns Seq[String] = List(five, six)
            arguments.getOptionArray("noValues", Seq("five", "six"))
        }
    
    }
    key

    The argument key

  16. def getOptionArray(key: String): Option[Seq[String]]

    Permalink

    Get a list of String for a single CLI argument.

    Get a list of String for a single CLI argument. Comma , is used as a separator character. This is useful when you need to process an arguments passed as --severalValues one,two,three. Returns None if the key does not exist.

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--severalValues", "one,two,three")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
            // Returns Option[Seq[String]] = Some(WrappedArray(one, two, three))
            arguments.getOptionArray("severalValues")
        }
    }
    key

    The argument key

  17. def getTypeOption[A](key: String)(implicit m: Manifest[A]): Option[A]

    Permalink

    Get the A value of an argument.

    Get the A value of an argument. This is useful when you need to process an argument which is one of:

    • String
    • Boolean
    • Int
    • Long
    • Float
    • Double

    An example of such argument list is --aString str --aBoolean true --anInt 201 --aLong 343 --aFloat 10.4 --aDouble 14.3

    Will return None if the key does not exist.

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--aString", "str", "--aBoolean", "true", "--anInt", "201", "--aLong", "343", "--aFloat", "10.4", "--aDouble", "14.3")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
    
            // Returns Option[String] = Some("str")
            arguments.getTypeOption[String]("aString")
    
            // Returns Option[Boolean] = None
            arguments.getTypeOption[Boolean]("notBoolean")
    
            // Returns Boolean = Some(true)
            arguments.getTypeOption[Boolean]("aBoolean")
    
            // Returns Int = Some(201)
            arguments.getTypeOption[Int]("anInt")
    
            // Returns Long = Some(343)
            arguments.getTypeOption[Long]("aLong")
    
            // Returns Float = Some(10.4)
            arguments.getTypeOption[Float]("aFloat")
    
            // Returns Double = Some(14.3)
            arguments.getTypeOption[Double]("aDouble")
        }
    
    }
    key

    The argument key

  18. def getTypeOption[A](key: String, default: A): A

    Permalink

    Get the A value of an argument, or a user-provided A in case the argument does not exist.

    Get the A value of an argument, or a user-provided A in case the argument does not exist. This is useful when you need to process an argument which is one of:

    • String
    • Boolean
    • Int
    • Long
    • Float
    • Double

    An example of such argument list is --aString str --aBoolean true --anInt 201 --aLong 343 --aFloat 10.4 --aDouble 14.3.

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--aString", "str", "--aBoolean", "true", "--anInt", "201", "--aLong", "343", "--aFloat", "10.4", "--aDouble", "14.3")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
    
            // Returns String = "str"
            arguments.getTypeOption[String]("aString", "a")
    
            // Returns Boolean = false
            arguments.getTypeOption[Boolean]("notBoolean", false)
    
            // Returns Boolean = true
            arguments.getTypeOption[Boolean]("aBoolean", false)
    
            // Returns Int = 201
            arguments.getTypeOption[Int]("anInt", 3)
    
            // Returns Long = 343
            arguments.getTypeOption[Long]("aLong", 678)
    
            // Returns Float = 10.4
            arguments.getTypeOption[Float]("aFloat", 134.43F)
    
            // Returns Double = 14.3
            arguments.getTypeOption[Double]("aDouble", 4523.53)
        }
    
    }
    key

    The argument key

  19. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  20. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  21. def isSet(key: String): Boolean

    Permalink

    Check if a flag is set.

    Check if a flag is set. This is useful when you need to process an argument passed as --turnItOn. Will return false if the flag is not present in the arguments list. Returns true otherwise.

    Example:

    import com.audienceproject.cli.Arguments
    
    object Test {
    
        // args: Array("--turnItOn")
        def main(implicit args: Array[String]) {
            val arguments = new Arguments
            // Returns Boolean = true
            arguments.isSet("turnItOn")
            // Returns Boolean = false
            arguments.isSet("turnItOff")
        }
    
    }
    key

    The argument key

  22. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  23. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  26. final def toPairs(base: Map[String, Option[String]], arr: Array[String]): Map[String, Option[String]]

    Permalink
    Annotations
    @tailrec()
  27. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  28. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  30. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped