Command Line Configuration (CLIC) Library

A library to provide two different methods of incorporating command line arguments into an application:

  1. Convert properties to and from command line arguments using any number of predefined properties files, as well as convert the properties to enable printing help using --help; and
  2. An API that enables configuration files to be written to define options, arguments and commands for an application that are baked in to the application. On application start, the configuration file is read and command line arguments passed to the API for processing; custom listeners are written and updated as each argument is read from the command line.

The terms CLIC and CLC can be used interchangeably and mean the same thing: command line configuration.

Under the hood the project uses Apache commons-cli to parse command line arguments. Supported properties implementations are java.util.Properties and org.apache.commons.configuration2.PropertiesConfiguration.

In more detail, the API enables properties-based and configuration-based methods to utilise command line arguments for any given application:

  1. Loading of properties files and convert them into command line arguments, enabling rapid prototyping of new (and existing) applications. In turn any command line arguments supplied will be used to override the property that the command line switch represents. Callers provide at least one properties file and the properties are then parsed into a valid CLC file. Once parsed, all command line switches that are supplied on the command line override the properties that have been read in. Using the API it is possible to convert properties to different types other than strings such as booleans, integer and floating point types. In addition custom CLC entries can be inserted using an overrides file to further customise properties on an individual basis; and

  2. Provides the CLC format for defining a configuration that is used to define command line options and arguments as well as commands; all that's needed is to create a custom CLC format file for use within an application and to write required listeners to be informed of updates as command line arguments are processed.

    The CLC format can be packaged directly into the application and code written to load the CLC at application start. All that's required (when not using properties, outlined above) is to write a listener class to receive updated options from the CLC as it loads and command line arguments are passed to it. Callers can then simply access the listener to get the values of the arguments once they've been processed.

In both cases, CLC offers some of the following benefits (the rest are outlined in the main CLC format section, below):