Clad User Manual: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 37: Line 37:
Implement the [https://github.com/NovaOrdis/clad/blob/master/src/main/java/io/novaordis/clad/command/Command.java Command] interface.
Implement the [https://github.com/NovaOrdis/clad/blob/master/src/main/java/io/novaordis/clad/command/Command.java Command] interface.


The implementation class must be named <tt><command-name>Command</tt>. Example: <tt>PrintCommand</tt> will be matched to the <tt>print</tt> command.
The implementation class must be named <tt><command-name>Command</tt>. Example: <tt>PrintCommand</tt> will be matched to the <tt>print</tt> command. <tt>BusinessScenarioCommand</tt> will be matched to the <tt>business-scenario</tt> command.

Revision as of 04:46, 2 March 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]

Options

The options use the GNU command line convention:


 -o <value> | --option=<value>

Configuration File

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

Implementing a Command

Implement the Command interface.

The implementation class must be named <command-name>Command. Example: PrintCommand will be matched to the print command. BusinessScenarioCommand will be matched to the business-scenario command.