package examples.dustin.commandline.joptsimple;

import static java.lang.System.out;

import joptsimple.OptionParser;
import joptsimple.OptionSet;

import java.io.IOException;
import java.util.Arrays;

/**
 * Demonstrate command-line processes in Java with JOpt Simple.
 */
public class Main
{
   /**
    * Demonstration of command-line arguments processing with JOpt Simple.
    * @param arguments Command-line arguments.
    */
   public static void main(final String[] arguments)
   {
      final OptionParser optionParser = new OptionParser();
      final String[] fileOptions = {"f", "file"};
      optionParser.acceptsAll(Arrays.asList(fileOptions), "Path and name of file.").withRequiredArg().required();
      final String[] verboseOptions = {"v", "verbose"};
      optionParser.acceptsAll(Arrays.asList(verboseOptions), "Verbose logging.");
      final String[] helpOptions = {"h", "help"};
      optionParser.acceptsAll(Arrays.asList(helpOptions), "Display help/usage information").forHelp();
      final OptionSet options = optionParser.parse(arguments);
      if (options.has("help"))
      {
         printUsage(optionParser);
      }
      else
      {
         out.println("Will write to file " + options.valueOf("file") + " and verbosity is set to " + options.has("verbose"));
      }
   }

   /**
    * Write usage/help statement out to standard output using
    * the provided instance of {@code OptionParser}.
    *
    * @param parser Instance from which usage/help information
    *    will be written to standard output; must not be {@code null}.
    */
   private static void printUsage(final OptionParser parser)
   {
      try
      {
         parser.printHelpOn(out);
      }
      catch (IOException ioEx)
      {
         out.println("ERROR: Unable to print usage - " + ioEx);
      }
   }
}

@@ -551,107 +551,50 @@
     
-final String%5B%5D fileOptions = %7B%22f%22, %22file%22%7D;%0A      optionParser.acceptsAll(Arrays.asList(fileOptions
+optionParser.acceptsAll(asList(%22f%22, %22file%22
 ), %22
@@ -652,64 +652,8 @@
 ();%0A
-      final String%5B%5D verboseOptions = %7B%22v%22, %22verbose%22%7D;%0A
     
@@ -682,36 +682,29 @@
 All(
-Arrays.
 asList(
+%22v%22, %22
 verbose
-Options
+%22
 ), %22
@@ -733,107 +733,50 @@
     
-final String%5B%5D helpOptions = %7B%22h%22, %22help%22%7D;%0A      optionParser.acceptsAll(Arrays.asList(helpOptions
+optionParser.acceptsAll(asList(%22h%22, %22help%22
 ), %22

Use statically imported Arrays.asList(String...)