Unknown arguments not given to an option will be stored here.
Define a command that will run the given class with usage
and
description
.
Define a command that will run the given class with usage
and
description
.
The command will be defined as the hyphenated name of the class (e.g.,
SomeClass -> some-class). You can choose your own name for the command by
providing it as the first word (beginning with a word character) in the
usage
parameter.
If the command name is given as the first argument on the command line,
it will run a method with the signature main(args: Array[String])
of the given class with the remaining arguments. That class should
define another program in the main method to handle the remaining arguments.
Examples:
// If ./program install-package is given on the command line, it will run InstallPackage.main() with the remaining args. program.command(classOf[InstallPackage], "[package]", "Install the given package") // Override the name of the command to `install` program.command(classOf[InstallPackage], "install [package]", "Install the given package")
The class that will handle this command. It should have a method with signature main(args: Array[String]) that will be called with remaining arguments.
Usage that will be displayed in the help message. The first word will be the name of the command if it begins with a word character.
Description of this command to be displayed in the help string.
Returns the program for chaining.
Set a description for this program
Set a description for this program
the description of this program
A useful description to be printed in the help string of this program.
Set an epilogue message for this program
Set an epilogue message for this program
the epilogue message
Additional information to be printed at the end of the help string in this program.
Print help information and exit
Get a help string for this program.
Define option with flags
, description
and optional
coercion fn
.
Define option with flags
, description
and optional
coercion fn
.
The flags
string should contain both the short and long flags,
separated by comma, a pipe or space. The following are all valid
all will output this way when --help
is used.
"-p, --pepper" "-p|--pepper" "-p --pepper"
Examples:
// simple boolean defaulting to false program.option("-p, --pepper", "add pepper") // option with optional parameter defaulting to "marble" program.option("-c, --cheese [type]", "add cheese", default="marble") // option with required parameter program.option("-b, --bbq-sauce", "add bbq sauce") // option that is coerced to an integer program.option("-n, --num [num]", "number of pizzas", default=1, fn=(_.toInt)) // option that is required for the program to run program.option("-C, --crust ", required=true)
The flags for this option (see example)
Description of this option for the help string
The default value when this option is not given
Whether this option is required for the program to run
Coercion function that takes the string value given on the command line and returns the value that will be given on the program object
Parse command line args
Parse command line args
Args given to the main()
method.
Options will be set dynamically on this class in camelcase form.
Options will be set dynamically on this class in camelcase form. Do not use this method directly.
the name of the option to get a value for
Set usage information for this program
Set usage information for this program
the usage information
Custom usage information to be printed in the help string
Set the version of this program.
Set the version of this program.
the version of this program
The version of this program.
The version of this program. This will be printed when -v
or --version
is given on the command line (TODO).
The program is a class used to parse command line arguments. Add options to this class with
Program::option()
. Parse arguments you get from themain()
method withProgram::parse()
. The values of the options will be dynamically set on this object in camelcase form. Example: