X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fde%2Ftodesbaum%2Fjsite%2Fmain%2FCLI.java;h=40f16df00e660679bbed47a44207fc21eb8fe108;hb=a6bda7a82aa1b2cfd0313fb28d3dcca68ca516c5;hp=03ddb50382ca4933cd8f686f70df2d7ada822352;hpb=418364b4db9be919ed85830a8d1a67e213cfdd80;p=jSite.git diff --git a/src/de/todesbaum/jsite/main/CLI.java b/src/de/todesbaum/jsite/main/CLI.java index 03ddb50..40f16df 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–2011 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 @@ -26,6 +25,7 @@ import de.todesbaum.jsite.application.InsertListener; import de.todesbaum.jsite.application.Node; import de.todesbaum.jsite.application.Project; import de.todesbaum.jsite.application.ProjectInserter; +import de.todesbaum.util.io.StreamCopier.ProgressListener; /** * Command-line interface for jSite. @@ -68,6 +68,7 @@ public class CLI implements InsertListener { if ((args.length == 0) || args[0].equals("-h") || args[0].equals("--help")) { outputWriter.println("\nParameters:\n"); + outputWriter.println(" --config-file="); outputWriter.println(" --node="); outputWriter.println(" --project="); outputWriter.println(" --local-directory="); @@ -79,11 +80,19 @@ public class CLI implements InsertListener { return; } - Configuration configuration = new Configuration(); - if (!configuration.createLockFile()) { - outputWriter.println("Lock file found!"); - return; + String configFile = System.getProperty("user.home") + "/.jSite/config7"; + for (String argument : args) { + String value = argument.substring(argument.indexOf('=') + 1).trim(); + if (argument.startsWith("--config-file=")) { + configFile = value; + } + } + + ConfigurationLocator configurationLocator = new ConfigurationLocator(); + if (configFile != null) { + configurationLocator.setCustomLocation(configFile); } + Configuration configuration = new Configuration(configurationLocator, configurationLocator.findPreferredLocation()); projectInserter.addInsertListener(this); projects = configuration.getProjects(); @@ -97,6 +106,10 @@ public class CLI implements InsertListener { Project currentProject = null; for (String argument : args) { + if (argument.startsWith("--config-file=")) { + /* we already parsed this one. */ + continue; + } String value = argument.substring(argument.indexOf('=') + 1).trim(); if (argument.startsWith("--node=")) { Node newNode = getNode(value); @@ -143,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."); } @@ -153,6 +168,8 @@ public class CLI implements InsertListener { configuration.setProjects(projects); configuration.save(); + + System.exit(errorCode); } /** @@ -201,7 +218,12 @@ public class CLI implements InsertListener { return false; } projectInserter.setProject(currentProject); - projectInserter.start(); + projectInserter.start(new ProgressListener() { + + public void onProgress(long copied, long length) { + System.out.print("Uploaded: " + copied + " / " + length + " bytes...\r"); + } + }); synchronized (lockObject) { while (!finished) { try { @@ -229,7 +251,7 @@ public class CLI implements InsertListener { * {@inheritDoc} */ public void projectUploadFinished(Project project) { - outputWriter.println("Project \"" + project.getName() + "\" has ben uploaded, starting insert..."); + outputWriter.println("Project \"" + project.getName() + "\" has been uploaded, starting insert..."); } /**