Packages

final class Flags extends AnyRef

A simple flags implementation. We support only two formats:

for flags with optional values (e.g. booleans): -flag, -flag=value for flags with required values: -flag[= ]value

That's it. These can be parsed without ambiguity.

There is no support for mandatory arguments: That is not what flags are for.

Flags.apply adds a new flag to the flag set, so it is idiomatic to assign instances of Flags to a singular flag val:

val flag = new Flags("myapp")
val i = flag("i", 123, "iteration count")

Global flags, detached from a particular Flags instance but accessible to all, are defined by com.twitter.app.GlobalFlag.

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

Instance Constructors

  1. new Flags(argv0: String)
  2. new Flags(argv0: String, includeGlobal: Boolean)
  3. new Flags(argv0: String, includeGlobal: Boolean, failFastUntilParsed: Boolean)

    argv0

    The name of the application that is to be configured via flags

    includeGlobal

    If true, GlobalFlags will be included during flag parsing. If false, only flags defined in the application itself will be consulted.

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. def add(f: Flag[_]): Unit

    Add a flag.

    Add a flag. The canonical way to do so is via Flags#apply, but this method is left public for any rare edge cases where it is necessary.

    f

    A concrete Flag to add

  5. def apply[T](name: String, help: String)(implicit _f: Flaggable[T], m: ClassTag[T]): Flag[T]

    Add a named flag with a help message.

    Add a named flag with a help message.

    name

    The name of the flag.

    help

    The help string of the flag.

  6. def apply[T](name: String, default: => T, help: String)(implicit arg0: Flaggable[T]): Flag[T]

    Add a named flag with a default value and a help message.

    Add a named flag with a default value and a help message.

    name

    The name of the flag.

    default

    A default value, as a thunk.

    help

    The help string of the flag.

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  9. def create[T](name: String, default: T, help: String, flaggable: Flaggable[T]): Flag[T]

    A Java-friendly method for adding named flags.

    A Java-friendly method for adding named flags.

    name

    The name of the flag.

    default

    A default value.

    help

    The help string of the flag.

  10. def createMandatory[T](name: String, help: String, usage: String, flaggable: Flaggable[T]): Flag[T]

    A Java-friendly way to create mandatory flags

    A Java-friendly way to create mandatory flags

    name

    the name passed on the command-line

    help

    the help text explaining the purpose of the flag

    usage

    a string describing the type of the flag, i.e.: Integer

  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  14. def formattedFlagValues(includeGlobal: Boolean = this.includeGlobal, classLoader: ClassLoader = this.getClass.getClassLoader): (Iterable[String], Iterable[String])

    Formats all values of all flags known to this instance into a format suitable for logging.

    Formats all values of all flags known to this instance into a format suitable for logging.

    includeGlobal

    See getAll above.

    classLoader

    See getAll above.

    returns

    All of the flag values in alphabetical order, grouped into (set, unset).

  15. def formattedFlagValuesString(includeGlobal: Boolean = this.includeGlobal, classLoader: ClassLoader = this.getClass.getClassLoader): String

    Creates a string containing all values of all flags known to this instance into a format suitable for logging.

    Creates a string containing all values of all flags known to this instance into a format suitable for logging.

    includeGlobal

    See getAll above.

    classLoader

    Set getAll above

    returns

    A string suitable for logging.

  16. def getAll(includeGlobal: Boolean = this.includeGlobal, classLoader: ClassLoader = this.getClass.getClassLoader): Iterable[Flag[_]]

    Get all of the flags known to this Flags instance.

    Get all of the flags known to this Flags instance.

    includeGlobal

    If true, all registered GlobalFlags will be included in output. Defaults to the includeGlobal settings of this instance.

    classLoader

    The java.lang.ClassLoader used to fetch GlobalFlags, if necessary. Defaults to this instance's classloader.

    returns

    All of the flags known to this this Flags instance.

  17. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  21. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  23. def parseArgs(args: Array[String], allowUndefinedFlags: Boolean = false): FlagParseResult

    Parse an array of flag strings.

    Parse an array of flag strings.

    args

    The array of strings to parse.

    allowUndefinedFlags

    If true, undefined flags (i.e. those that are not defined in the application via a flag.apply invocation) are allowed. If false, undefined flags will result in a FlagParseException being thrown.

    returns

    A com.twitter.app.Flags.FlagParseResult representing the result of parsing args.

  24. def parseOrExit1(args: Array[String], undefOk: Boolean = true): Seq[String]

    Parse an array of flag strings or exit the application (with exit code 1) upon failure to do so.

    Parse an array of flag strings or exit the application (with exit code 1) upon failure to do so.

    args

    The array of strings to parse.

    undefOk

    If true, undefined flags (i.e. those that are not defined in the application via a flag.apply invocation) are allowed. If false, undefined flags will result in a FlagParseException being thrown.

  25. def registeredDuplicates: Set[String]

    Return the set of any registered duplicated flag names.

    Return the set of any registered duplicated flag names.

    Attributes
    protected[twitter]
  26. def reset(): Unit
  27. def setCmdUsage(u: String): Unit

    Set the flags' command usage; this is a message printed before the flag definitions in the usage string.

  28. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  29. def toString(): String
    Definition Classes
    AnyRef → Any
  30. def usage: String
  31. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  32. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  33. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def parse(args: Array[String], undefOk: Boolean = false): Seq[String]

    Parse an array of flag strings.

    Parse an array of flag strings.

    args

    The array of strings to parse.

    undefOk

    If true, undefined flags (i.e. those that are not defined in the application via a flag.apply invocation) are allowed. If false, undefined flags will result in a FlagParseException being thrown.

    Annotations
    @deprecated
    Deprecated

    (Since version 6.17.1) Prefer result-value based Flags.parseArgs method

    Exceptions thrown

    FlagParseException if an error occurs during flag-parsing.

    Note

    This method has been deprecated in favor of Flags.parseArgs, which indicates success or failure by returning com.twitter.app.Flags.FlagParseResult rather than relying on thrown exceptions.

Inherited from AnyRef

Inherited from Any

Ungrouped