package es.tid.cosmos.platform.injection.server;

import org.apache.commons.cli.*;

/**
 * @author sortega
 */
public class ServerCommandLine {
    private static final String CONFIG_FILE = "c";

    private final GnuParser parser;
    private final Options options;
    private CommandLine commandLine;

    public ServerCommandLine() {
        this.parser = new GnuParser();
        this.options = new Options().addOption(CONFIG_FILE, "config", true,
                                               "Configuration file");
    }

    public void parse(String[] args) throws ParseException {
        this.commandLine = this.parser.parse(this.options, args.clone());
    }

    public void printUsage() {
        new HelpFormatter().printHelp("injection-server", this.options);
    }

    public boolean hasConfigFile() {
        return this.commandLine.hasOption(CONFIG_FILE);
    }

    public String getConfigFile() {
        return this.commandLine.getOptionValue(CONFIG_FILE);
    }
}

@@ -169,16 +169,22 @@
  String 
+SHORT_
 CONFIG_F
@@ -193,16 +193,77 @@
 E = %22c%22;
+%0A    private static final String LONG_CONFIG_FILE = %22config%22;
 %0A%0A    pr
@@ -480,24 +480,30 @@
 ).addOption(
+SHORT_
 CONFIG_FILE,
@@ -506,23 +506,72 @@
 ILE,
- %22config%22, true
+%0A                                               LONG_CONFIG_FILE
 ,%0A  
@@ -614,16 +614,22 @@
         
+ true,
  %22Config
@@ -983,16 +983,22 @@
 sOption(
+SHORT_
 CONFIG_F
@@ -1093,16 +1093,22 @@
 onValue(
+SHORT_
 CONFIG_F

Define constants in ServerCommandLine.