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.
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());
}
}
Our Converters include:
- CipherConverter
- ExemptionMechanismConverter
- KeyAgreementConverter
- KeyGeneratorConverter
- MacConverter
- SecretKeyFactoryConverter
- AlgorithmParameterGeneratorConverter
- AlgorithmParametersConverter
- KeyFactoryConverter
- KeyPairGeneratorConverter
- KeyStoreConverter
- MessageDigestConverter
- ProviderConverter
- SecureRandomConverter
- SignatureConverter
- ConnectionConverter
- DateConverter
- DriverConverter
- TimeConverter
- TimestampConverter
- TypesConverter
- MicrosoftTypesConverter
- MysqlTypesConverter
- OracleTypesConverter
- DurationConverter
- InstantConverter
- LocalDateConverter
- LocalDateTimeConverter
- LocalTimeConverter
- MonthDayConverter
- OffsetDateTimeConverter
- OffsetTimeConverter
- PeriodConverter
- YearConverter
- YearMonthConverter
- ZonedDateTimeConverter
- ZoneIdConverter
- ZoneOffsetConverter
To make sure everything is OK, build from first principles and run all the tests:
mvn clean test
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
To deploy a SNAPSHOT build to the SNAPSHOT repository, run:
mvn clean deploy
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
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
This project follows Semantic Versioning.