package com.phsshp.config;

import org.apache.commons.cli.*;

public class CommandLineParser {

    private final Options options;

    public CommandLineParser() {
        options = new Options();
    }

    public String parse(String args[]) {
        DefaultParser parser = new DefaultParser();

        try {
            CommandLine commandLine = parser.parse(options, args);
            if (commandLine.getArgList().size() == 0) {
                printHelpAndExit();
            }
            return commandLine.getArgList().get(0);
        } catch (ParseException e) {
            System.out.println("Could not parse: " + e.getMessage());
            printHelpAndExit();
            return null;
        }
    }

    private void printHelpAndExit() {
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp("java-code-metrics", "Code metrics for Java source code", options, "");
        System.exit(1);
    }
}

@@ -187,24 +187,114 @@
  Options();%0A
+        options.addOption(%22output%22, true, %22Filename to save output (default is stdout)%22);%0A
     %7D%0A%0A    p
@@ -949,18 +949,54 @@
 -metrics
-%22,
+  %5BOPTION%5D... %5BFILE%5D%22,%0A               
  %22Code m

Add output option to list of allowed parameters