olua.app
Class Application

olua.lib.Object
└─ olua.app.Application

I am the base class for all Objective Lua standalone applications. I parse command line arguments and acts as the basis for a more complex application lifecycle system (as needed by a GUI, for example).

To run an application, the top-level code needed is:

return [[[YourApplicationSubclassHere alloc] init] runWithArgs: {...}]

Constructor Summary
- init
Initialises a new application instance.
Method Summary
- addOption: option withHandler: handler
Adds a single argument handler.
- addOptions: options
Adds a table of argument handlers.
- addOptions: options withHandler: handler
Adds several arguments with the same handler.
- error: e, ...
Throws a new instance of olua.app.ApplicationException with the specified message.
- name
Returns the name of the application.
- parseArguments: arguments
Parses an argument list.
- remainingArguments
Returns the unprocessed command line arguments.
- reportError: e
Reports an error to the user and halts.
- runWithArgs: args
Runs the application.
Method Detail

- addOption: option withHandler: handler

Adds a single argument handler.

- addOptions: options

Adds a table of argument handlers.

- addOptions: options withHandler: handler

Adds several arguments with the same handler.

- error: e, ...

Throws a new instance of olua.app.ApplicationException with the specified message.

Arguments are formatted with string.format.

- init

Initialises a new application instance.

Subclasses should override this and call -addOption:withHandler: or -addOptions: to add command-line option handlers.

- name

Returns the name of the application.

This should be overridden to contain the name of the application; it is used in error handling.

- parseArguments: arguments

Parses an argument list.

- remainingArguments

Returns the unprocessed command line arguments.

- reportError: e

Reports an error to the user and halts.

- run

Abstract method containing the application logic.

This method is called by -runWithArgs:. The default implementation does nothing; this should be overridden to contain the application logic. On error, this method should throw olua.app.ApplicationException.

- runWithArgs: args

Runs the application.

The command line arguments are passed (see olua.app.ArgumentParser>>-parse:), and then -run is called. If an olua.app.ApplicationException is thrown, it is reported nicely to the user with -reportError:.