Building the command-line interface
The primary means to interact with our new library will be the command-line interface we will now develop. Unfortunately, the Java SDK has nothing built in to help make sophisticated command-line utilities. If you've been using Java for any time, you've seen the following method signature:
public static void main(String[] args)
Clearly, there is a mechanism to process command-line arguments. The public static void main
method is passed string arrays that represent arguments provided by the user on the command line, but that's about as far as it goes. To parse the options, the developer is required to iterate over the array, analyzing each entry. It might look something like this:
int i = 0; while (i < args.length) { if ("--source".equals(args[i])) { System.out.println("--source = " + args[++i]); } else if ("--target".equals(args[i])) { System.out.println("--target = " + args[++i]); } else if ("--force...