com.twitter.app

App

trait App extends Closable with CloseAwaitably

A composable application trait that includes flag parsing as well as basic application lifecycle (pre- and post- main). Flag parsing is done via com.twitter.app.Flags, an instance of which is defined in the member flag. Applications should be constructed with modularity in mind, and common functionality should be extracted into mixins.

Flags should only be constructed in the constructor, and should only be read in the premain or later, after they have been parsed.

object MyApp extends App {
val n = flag("n", 100, "Number of items to process")

def main() {
  for (i <- 0 until n()) process(i)
}
}

Note that a missing main is OK: mixins may provide behavior that does not require defining a custom main method.

Linear Supertypes
CloseAwaitably, Awaitable[Unit], Closable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. App
  2. CloseAwaitably
  3. Awaitable
  4. Closable
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

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

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

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

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final val MinGrace: Duration

    Minimum duration to allow for exits to be processed.

  7. def allowUndefinedFlags: Boolean

    Whether or not to accept undefined flags

    Whether or not to accept undefined flags

    Attributes
    protected
  8. def args: Array[String]

    The remaining, unparsed arguments

  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. final def close(deadline: Time): Future[Unit]

    Notify the application that it may stop running.

    Notify the application that it may stop running. Returns a Future that is satisfied when the App has been torn down or errors at the deadline.

    Definition Classes
    App → Closable
  12. def close(after: Duration): Future[Unit]

    Definition Classes
    Closable
  13. final def close(): Future[Unit]

    Definition Classes
    Closable
  14. def closeAwaitably(f: ⇒ Future[Unit]): Future[Unit]

    Attributes
    protected
    Definition Classes
    CloseAwaitably
  15. final def closeOnExit(closable: Closable): Unit

    Close closable when shutdown is requested.

    Close closable when shutdown is requested. Closables are closed in parallel.

    Attributes
    protected
  16. def defaultCloseGracePeriod: Duration

    Default amount of time to wait for shutdown.

    Default amount of time to wait for shutdown. This value is not used as a default if close() is called without parameters. It simply provides a default value to be passed as close(grace).

  17. final def eq(arg0: AnyRef): Boolean

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

    Definition Classes
    AnyRef → Any
  19. def exitOnError(reason: String): Unit

    Attributes
    protected
  20. def failfastOnFlagsNotParsed: Boolean

    Attributes
    protected
  21. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  22. val flag: Flags

    The com.twitter.app.Flags instance associated with this application

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

    Definition Classes
    AnyRef → Any
  24. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  25. final def init(f: ⇒ Unit): Unit

    Invoke f before anything else (including flag parsing).

    Invoke f before anything else (including flag parsing).

    Attributes
    protected
  26. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  27. def isReady(implicit permit: CanAwait): Boolean

    Definition Classes
    CloseAwaitably → Awaitable
  28. final def main(args: Array[String]): Unit

  29. val name: String

    The name of the application, based on the classname

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

    Definition Classes
    AnyRef
  31. final def notify(): Unit

    Definition Classes
    AnyRef
  32. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  33. final def onExit(f: ⇒ Unit): Unit

    Invoke f when shutdown is requested.

    Invoke f when shutdown is requested. Exit hooks run in parallel and all must complete before postmains are executed.

    Attributes
    protected
  34. final def postmain(f: ⇒ Unit): Unit

    Invoke f after the user's main has exited.

    Invoke f after the user's main has exited.

    Attributes
    protected
  35. final def premain(f: ⇒ Unit): Unit

    Invoke f right before the user's main is invoked.

    Invoke f right before the user's main is invoked.

    Attributes
    protected
  36. def ready(timeout: Duration)(implicit permit: CanAwait): App.this.type

    Definition Classes
    CloseAwaitably → Awaitable
  37. def result(timeout: Duration)(implicit permit: CanAwait): Unit

    Definition Classes
    CloseAwaitably → Awaitable
  38. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  39. def toString(): String

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

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from CloseAwaitably

Inherited from Awaitable[Unit]

Inherited from Closable

Inherited from AnyRef

Inherited from Any

Ungrouped