Skip to content

Latest commit

 

History

History
251 lines (180 loc) · 14.2 KB

README.md

File metadata and controls

251 lines (180 loc) · 14.2 KB

jcommander-addons

JCommander is a small Java framework that makes it simple to parse command line parameters.

The goal of the JCommander-Addons project is to provide any and all JCommander converters and validators an advanced applications will need.

Feel free to submit a pull-request and examine the sources and build site.

Build Status Build status Coverage Status Maven Central

Examples

To convert a command line argument into a Duration object, you write:

@Parameter(names = { "--duration" }, converter = DurationConverter.class)
private Duration duration;

Here is a complete program using a LocalDate:

package com.garygregory.jcommander.examples;

import java.time.LocalDate;

import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.garygregory.jcommander.converters.time.LocalDateConverter;

public class SimpleExample {

    @Parameter(
      names = { "--dob", "-d" }, 
      converter = LocalDateConverter.class, 
      required = true, 
      description = "Birthday in the format YYYY-MM-DD, for example 2007-12-03")
    LocalDate localDate;

    public static void main(String... args) {
        SimpleExample main = new SimpleExample();
        new JCommander(main, args);
        main.run();
    }

    public void run() {
        System.out.printf("You were born on a %s.", localDate.getDayOfWeek());
    }

}

Converters

Our Converters include:

Crypto Converters

Lang Converters

Math Converters

Net Converters

Net SSL Converters

NIO Converters

Security Converters

Security Certificate Converters

SQL Converters

Time Converters

Util Converters

XML Converters

Status

Build Status Coverage Status Maven Central

Building

Testing

To make sure everything is OK, build from first principles and run all the tests:

mvn clean test

Validating a patch or pull request

If you want to submit a patch or pull request, make sure all is well:

mvn apache-rat:check
mvn clirr:check
mvn clean site

Deploying a SNAPSHOT

To deploy a SNAPSHOT build to the SNAPSHOT repository, run:

mvn clean deploy

Generating the site

The site is generated in target/docs and manually copied to the docs folder for publication to GitHub Pages at https://garydgregory.github.io/jcommander-addons.

To generate the site run:

mvn clean site site:stage -DstagingDirectory=target/docs

Releasing a new version

Make sure all is well in your development branch:

mvn apache-rat:check
mvn clirr:check
mvn clean site

Create a clean clone and make sure all is well:

git clone https://github.com/garydgregory/jcommander-addons.git jcommander-addons-1.0.0-rc1
cd jcommander-addons-1.0.0-rc1
mvn apache-rat:check
mvn clirr:check
mvn clean site

Set the version from SNAPSHOT to normal and create a signed tag:

mvn versions:set -DnewVersion=1.0.0 -DgenerateBackupPoms=false
git commit -am "Update version numbers for release jcommander-addons 1.0.0"
mvn deploy -Prelease
git tag -s 1.0.0 -m "Tag release jcommander-addons 1.0.0" -u "[email protected]"
git push origin 1.0.0

Now reset the version to the next version:

mvn versions:set -DnewVersion=1.1.0-SNAPSHOT -DgenerateBackupPoms=false
git commit -am "Update to the version to 1.1.0-SNAPSHOT after releasing 1.0.0"
git push

Versioning

This project follows Semantic Versioning.