import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
public class MyApp {
@Parameter(names = { "-n", "--name" }, description = "Your name", required = true)
private String name;
@Parameter(names = { "-a", "--age" }, description = "Your age", required = true)
private int age;
public static void main(String[] args) {
MyApp app = new MyApp();
JCommander.newBuilder()
.addObject(app)
.build()
.parse(args);
System.out.println("Hello, " + app.name + "! You are " + app.age + " years old.");
}
}
public class MyApp {
public static void main(String[] args) {
JCommander.newBuilder()
.addObject(app)
.setParameterDescriptionComparator(new CustomComparator())
.build()
.parse(args);
}
}
class CustomComparator implements Comparator<ParameterDescription> {
@Override
public int compare(ParameterDescription pd1, ParameterDescription pd2) {
}
}