[Bugfix] fixed NPE when CLI argument is missing

This commit is contained in:
Robert von Burg 2014-02-17 21:46:23 +01:00
parent a7e4faa5c1
commit c1a84fc480
1 changed files with 6 additions and 2 deletions

View File

@ -39,13 +39,17 @@ import org.slf4j.LoggerFactory;
public class MainStarter {
private static final Logger logger = LoggerFactory.getLogger(MainStarter.class);
private static final String OPT_ROOT_PATH = "root-path";
private Options options;
private StrolchAgent agent;
public MainStarter() {
Options op = new Options();
Option rootPathOption = new Option("p", "root-path", true, "root path to strolch runtime");
Option rootPathOption = new Option("p", OPT_ROOT_PATH, true, "root path to strolch runtime");
rootPathOption.setOptionalArg(false);
rootPathOption.setRequired(true);
op.addOption(rootPathOption);
this.options = op;
}
@ -65,7 +69,7 @@ public class MainStarter {
return 1;
}
String pathS = line.getOptionValue("root-path");
String pathS = line.getOptionValue(OPT_ROOT_PATH);
File pathF = new File(pathS);
if (!pathF.exists()) {
logger.info(MessageFormat.format("Path parameter does not exist at: {0}", pathS));