- Index
- »
- util
- »
- AbstractMain
type
AbstractMain
src
abstract class AbstractMain : Obj
AbstractMain provides conveniences for writing the main routine of an app. Command line arguments are configured as fields with the Arg
facet:
@Arg { help = "source file to process" } File? src
Arguments are ordered by the field declaration order. The last argument may be declared as a list to handle a variable numbers of arguments.
Command line options are configured as fields with the Opt
facet :
@Opt { help = "http port"; aliases=["p"] } Int port := 8080
Bool fields should always default to false and are considered flag options. All other arg and opt fields must be a Str, File, or have a type which supports a fromStr
method.
Option fields may include the "Opt" suffix, and arguments the "Arg" suffix. These suffixes can be used when a field conflicts with an existing slot name.
AbstractMain will automatically implement usage
and parseArgs
based on the fields which are declared as options and arguments. In general subclasses only need to override run
. If writing a daemon main, then you'll probably want to configure your services then call runServices
.
See example.
fields
helpOpt |
Print usage help. |
---|
methods
appName |
Get the application name. |
---|---|
argFields |
Get all the fields annotated with the |
homeDir |
Home directory for the application. |
log |
Log for this application; defaults to |
main |
Main performs the following tasks |
optFields |
Get all the fields annotated with the |
parseArgs |
Parse the command line and set this instances fields. |
run |
Run the application. |
runServices |
Run the set of services |
usage |
Print usage of arguments and options. |
Slot Details
appName
argFields
helpOpt
homeDir
log
main
optFields
parseArgs
run
Run the application. This method is called after the command line has been parsed. See runServices
to launch a deamon application. Return status code, zero for success.