Clad User Manual: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 45: Line 45:


@COMMANDS@ - inserts the list of commands available to the application. The runtime builds that list via introspection looking for classes that implement the Command interface.
@COMMANDS@ - inserts the list of commands available to the application. The runtime builds that list via introspection looking for classes that implement the Command interface.
=Error Handling=
If a processing error is caused by what the user did, or by the input data, and it can be corrected by user input (or by data correction), throw an UserErrorException with a human-readable message. The upmost runtime layer must be designed so it displays the error message at stderr and System.exit()s.

Revision as of 18:15, 8 November 2016

Internal

Overview

The framework scans the command line looking for the first argument that can be mapped to a command.

The mapping process involves scanning the classpath and looking for classes implementing the Command interface. The current version does not introspect all classes, but just those whose simple class name match the following pattern: <commandName>Command.

All arguments between the wrapper name and the command name are interpreted as global options.

All arguments following the command name are interpreted as command options.


   wrapper [global-options] command [command-options]

Subjects

Concepts
How to Implement a Command Line Application

Configuration File

Each command line option has a configuration file correspondent. Command line value takes precedence over the configuration file value.

In-line Application Help

If a text file named <application-name>.txt is placed in the same package as the ApplicationRuntime implementation class, its content is rendered to stdout every time the in-line application help is invoked with no-argument "help" command:

   <app-name> help|--help|-h

The length of a text line should not be larger than 99.

Macros

The help renderer recognizes several macros, which are replaced by dynamically generated content at runtime.

@COMMANDS@ - inserts the list of commands available to the application. The runtime builds that list via introspection looking for classes that implement the Command interface.