Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.selesse.jxlint.cli;
  
  
  import java.util.List;

Class for extracting program options from org.apache.commons.cli.CommandLine and org.apache.commons.cli.Options. A wrapper so that if the CLI parser changes, code modifications will be limited to this class.
 
 public class ProgramOptionExtractor {
     public static final String DEFAULT_PORT = "8380";
     static final String HTML_OPTION = "html";
     static final String XML_OPTION = "xml";
     static final String QUIET_OPTION = "quiet";
 
     public static ProgramOptions extractProgramOptions(CommandLine commandLine) {
         ProgramOptions programOptions = new ProgramOptions();
 
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption(..getOptionString())) {
             String port = commandLine.getOptionValue(..getOptionString(), );
             programOptions.addOption(.port);
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.,
                     commandLine.getOptionValue(..getOptionString()));
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.,
                     commandLine.getOptionValue(..getOptionString()));
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.,
                     commandLine.getOptionValue(..getOptionString()));
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.,
                     commandLine.getOptionValue(..getOptionString()));
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.,
                     commandLine.getOptionValue(..getOptionString()));
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption(..getOptionString())) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption()) {
             programOptions.addOption(.);
         }
         if (commandLine.hasOption()) {
             programOptions.addOption(.);
             String outputHtmlFile = commandLine.getOptionValue();
             if (outputHtmlFile != null) {
                 if (!outputHtmlFile.endsWith(".html")) {
                     outputHtmlFile += ".html";
                 }
                 programOptions.addOption(.outputHtmlFile);
             }
         }
         if (commandLine.hasOption()) {
             programOptions.addOption(.);
             String outputXmlFile = commandLine.getOptionValue();
             if (outputXmlFile != null) {
                 if (!outputXmlFile.endsWith(".xml")) {
                     outputXmlFile += ".xml";
                 }
                 programOptions.addOption(.outputXmlFile);
             }
         }
 
         @SuppressWarnings("unchecked"List<StringargList = commandLine.getArgList();
 
        if (argList.size() > 0) {
            programOptions.setSourceDirectory(argList.get(0));
        }
        return programOptions;
    }
New to GrepCode? Check out our FAQ X