X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fmain%2FCLI.java;h=c10f7df343c64cdd44f4d26e3dab9ac2ec24be52;hb=593eba180ca6538a680810651f127fbcf0a620a3;hp=c97d8e13f2c6368dd61eff7e900fbce4e337a3fb;hpb=3c46627c143cb41527eb05b2e91d10feb12dd914;p=jSite.git diff --git a/src/de/todesbaum/jsite/main/CLI.java b/src/de/todesbaum/jsite/main/CLI.java index c97d8e1..c10f7df 100644 --- a/src/de/todesbaum/jsite/main/CLI.java +++ b/src/de/todesbaum/jsite/main/CLI.java @@ -1,6 +1,5 @@ /* - * jSite - - * Copyright (C) 2006 David Roden + * jSite - CLI.java - Copyright © 2006–2012 David Roden * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -89,11 +88,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 +156,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 +168,8 @@ public class CLI implements InsertListener { configuration.setProjects(projects); configuration.save(); + + System.exit(errorCode); } /** @@ -217,6 +220,7 @@ public class CLI implements InsertListener { projectInserter.setProject(currentProject); projectInserter.start(new ProgressListener() { + @Override public void onProgress(long copied, long length) { System.out.print("Uploaded: " + copied + " / " + length + " bytes...\r"); } @@ -240,6 +244,7 @@ public class CLI implements InsertListener { /** * {@inheritDoc} */ + @Override public void projectInsertStarted(Project project) { outputWriter.println("Starting Insert of project \"" + project.getName() + "\"."); } @@ -247,6 +252,7 @@ public class CLI implements InsertListener { /** * {@inheritDoc} */ + @Override public void projectUploadFinished(Project project) { outputWriter.println("Project \"" + project.getName() + "\" has been uploaded, starting insert..."); } @@ -254,6 +260,7 @@ public class CLI implements InsertListener { /** * {@inheritDoc} */ + @Override public void projectURIGenerated(Project project, String uri) { outputWriter.println("URI: " + uri); } @@ -261,6 +268,7 @@ public class CLI implements InsertListener { /** * {@inheritDoc} */ + @Override public void projectInsertProgress(Project project, int succeeded, int failed, int fatal, int total, boolean finalized) { outputWriter.println("Progress: " + succeeded + " done, " + failed + " failed, " + fatal + " fatal, " + total + " total" + (finalized ? " (finalized)" : "") + ", " + ((succeeded + failed + fatal) * 100 / total) + "%"); } @@ -268,6 +276,7 @@ public class CLI implements InsertListener { /** * {@inheritDoc} */ + @Override public void projectInsertFinished(Project project, boolean success, Throwable cause) { outputWriter.println("Request URI: " + project.getFinalRequestURI(0)); finished = true;