Add options for configuration file location.
[jSite.git] / src / de / todesbaum / jsite / main / CLI.java
index c97d8e1..0780e9f 100644 (file)
@@ -89,11 +89,11 @@ public class CLI implements InsertListener {
                        }
                }
 
-               Configuration configuration = new Configuration(configFile);
-               if (!configuration.createLockFile()) {
-                       outputWriter.println("Lock file found!");
-                       return;
+               ConfigurationLocator configurationLocator = new ConfigurationLocator();
+               if (configFile != null) {
+                       configurationLocator.setCustomLocation(configFile);
                }
+               Configuration configuration = new Configuration(configurationLocator, configurationLocator.findPreferredLocation());
 
                projectInserter.addInsertListener(this);
                projects = configuration.getProjects();
@@ -157,9 +157,11 @@ public class CLI implements InsertListener {
                        }
                }
 
+               int errorCode = 1;
                if (currentProject != null) {
                        if (insertProject(currentProject)) {
                                outputWriter.println("Project \"" + currentProject.getName() + "\" successfully inserted.");
+                               errorCode = 0;
                        } else {
                                outputWriter.println("Project \"" + currentProject.getName() + "\" was not successfully inserted.");
                        }
@@ -167,6 +169,8 @@ public class CLI implements InsertListener {
 
                configuration.setProjects(projects);
                configuration.save();
+
+               System.exit(errorCode);
        }
 
        /**