Have a case class extend this trait for its fields to become command line arguments, and its body the core of your app using these.
Have a case class extend this trait for its fields to become command line arguments, and its body the core of your app using these.
Extends DelayedInit
, so that the body of the case class gets called later.
Remaining arguments are accessible via the method remainingArgs
.
Example
case class Foo( i: Int, foo: String ) extends App { // core of your app, using the fields above } object FooApp extends AppOf[Foo]
In the example above, FooApp
now has a main
method, that parses the arguments it is given,
and matches these to the fields i
(-i 2
gives i
the value 2
) and foo
(--foo ab
gives foo
the value "ab"
) of Foo
. It also accepts --help
/ -h
/ --usage
arguments,
and prints help or usage messages when these are present.
(Since version 1.2.0-M2) See CaseApp instead
Have a singleton extends this class to get a class with a main method for the app of T
Have a singleton extends this class to get a class with a main method for the app of T
(Since version 1.2.0-M2) Use CaseApp instead
Have a sealed trait extend this for its case class children to become commands.
Have a sealed trait extend this for its case class children to become commands.
Extends DelayedInit
like App
does.
Like with App
, the remaining arguments are accessible with the method remainingArgs
.
Example
sealed trait DemoCommand extends Command case class First( ) extends DemoCommand { // ... } case class Second( ) extends DemoCommand { // ... } object MyApp extends CommandAppOf[DemoCommand]
In the example above, MyApp
now has a main
method, that accepts arguments
like first a b
or second c d
. In the first case, it will create a First
, and
call its body (whose initialization is delayed thanks to delayed initialization). In the
second case, it will create a Second
instead, and call its body too.
(Since version 1.2.0-M2) See CommandApp instead
(Since version 1.2.0-M2) Use CommandApp instead
(Since version 1.2.0-M2) Use CommandAppWithPreCommand instead