CLOPS is a Java parser and documentation generator for command line options. CLOPS guarantees that your code and your documentation are in sync.
CLOPS makes it easy to evolve the command line interface of a Java application. Once the options multiply and the syntax of the command line becomes more complicated it becomes more and more advantageous to use CLOPS.
src/clops/foo.clo:
NAME:: Foo ARGS:: SayHi :{"--say-hi", "-sh" } :[allowArg="false",default="false"] :"Greets the user." SayBye :{"--say-bye", "-sb"} :{int} :[minValue="0",default="0"] :"Leaves." Help :{"--help", "-h"} :[allowArg="false",default="false"] :"Displays this message." FORMAT:: (SayHi | SayBye)* | Help;
Execute:
clops src/clops/foo.clo -o=src/java/foo/clops -p=foo.clops
src/java/foo/Main.java:
package foo; import java.util.*; import foo.clops.*; public class Main { public static void main(String[]args){ FooParser p = new FooParser(); List<CLError> errors = p.parse(args); if (!errors.isEmpty()) { report(errors, System.err); p.printUsage(System.out); } FooOptionsInterface opt = p.getOptionsInterface(); if (opt.getHelp()) p.printUsage(System.out); if (opt.getSayHi()) System.out.println("hi"); for (int i=opt.getSayBye(); --i>=0;) System.out.println("bye"); } }
If you are new to CLOPS, this is the place to start.
Make sure you downloaded the latest release of CLOPS before going through the tutorial.
You are using CLOPS for a while but you can't remember the syntax for the choices property of the enum option type? The reference is what you want.
The best way to get help on using CLOPS is to write to its mailing list, clops-users@lists.sourceforge.net. To subscribe, use mailman.