Clad User Manual - How to Implement a Command Line Application: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 34: Line 34:
TODO
TODO
</font>
</font>
==SLF4J Binding==
clad relies on SLF4J API, but does not enforce any binding. It is up to your application to define a binding among its dependencies. For more details see [[Slf4j#No_StaticLoggerBinder|SLF4J - No StaticLoggerBinder]].


=Wrapper=
=Wrapper=

Revision as of 17:46, 8 November 2016

Internal

Overview

Declare the Maven Dependency

<dependency>
    <groupId>io.novaordis.clad</groupId>
    <artifactId>novaordis-clad</artifactId>
    <version>...</version>
</dependency>

Provide an ApplicationRuntime Implementation

Extend ApplicationRuntimeBase, into a "clad" sub-package of your project. This is the recommended approach. If you need more flexibility, you can implement ApplicationRuntime interface.

The application runtime functionality is related to the following aspects:

Specify a Default Command

To provide a default command, implement public String getDefaultCommandName(). For more details on the default command, see "Default Command" section.

Define Global Options

For more details on the default command, see "Global Options" section.

Logging

TODO


SLF4J Binding

clad relies on SLF4J API, but does not enforce any binding. It is up to your application to define a binding among its dependencies. For more details see SLF4J - No StaticLoggerBinder.

Wrapper

java -cp ... io.novaordis.clad.CommandLineApplication

Application Name

The application name should be provided as a system property argument to java, in the wrapper:


-Dapplication.name=Release



Package the application runtime implementation class and the commands in a JAR (or place them in a directory).

Set “application.name” as a system property. If the application runtime implementation class is BlueApplicationRuntime, the application.name must be “blue”.

Make sure the JAR or the directory is first on the class path (otherwise other <your-command-name>Command.class, if exist, will be instantiated first).