java.lang.Object | +----Commandline
public String params[]
public Commandline(String argv[], String validflags, String validoptions, String validlongflags[], String validlongoptions[]) throws InvalidCommandlineArgument
public Commandline(String argv[], String validflags, String validoptions) throws InvalidCommandlineArgument
public boolean hasOption(Character option)hasOption
public boolean hasOption(String option)
public String getOption(Character option)getOption
public String getOption(String option)
public static void test(String in[], String flags, String opts, String longflags[], String longopts[])
import Commandline; class test { public static void main(String argv[]) { String in[] = { "-ac", "c_arg", "param-1", "--flaga", "--opta", "opta_arg" , "--", "-param-3", "param-4" }; String longflags[] = { "flaga", "flagb" }; String longopts[] = { "opta", "optb" }; Commandline.test(in, "ab", "cdef", longflags, longopts); } }which should output
Valid short options are: cdef (with args) and ab (without args). Valid long options are: opta optb Valid long flags are: flaga flagb Running with options: -ac c_arg param-1 --flaga --opta opta_arg -- -param-3 param-4 ... ... found option c with value c_arg ... didn't find option d ... didn't find option e ... didn't find option f ... found option a with value ... didn't find option b ... found option opta with value opta_arg ... didn't find option optb ... found option flaga with value ... didn't find option flagb ... Extra Parameters: param-1 -param-3 param-4 Done.
Converted using doccnv by Thomas Wendt