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") } }
The argument key
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") } }
The argument key
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") } }
The argument key
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") } }
The argument key
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")) } }
The argument key
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") } }
The argument key
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:
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") } }
The argument key
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:
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) } }
The argument key
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") } }
The argument key