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.
if ((args.length == 0) || args[0].equals("-h") || args[0].equals("--help")) {
outputWriter.println("\nParameters:\n");
+ outputWriter.println(" --config-file=<configuration file>");
outputWriter.println(" --node=<node name>");
outputWriter.println(" --project=<project name>");
outputWriter.println(" --local-directory=<local directory>");
return;
}
- Configuration configuration = new Configuration();
+ 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;
+ }
+ }
+
+ Configuration configuration = new Configuration(configFile);
if (!configuration.createLockFile()) {
outputWriter.println("Lock file found!");
return;
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);
}
}
+ 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.");
}
configuration.setProjects(projects);
configuration.save();
+
+ System.exit(errorCode);
}
/**
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 {
/**
* {@inheritDoc}
*/
+ public void projectUploadFinished(Project project) {
+ outputWriter.println("Project \"" + project.getName() + "\" has been uploaded, starting insert...");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void projectURIGenerated(Project project, String uri) {
outputWriter.println("URI: " + uri);
}