Sfoglia il codice sorgente

Library addition for a WIP change & small correction in a help msg

LH 9 anni fa
parent
commit
8fae21194c
26 ha cambiato i file con 903 aggiunte e 2 eliminazioni
  1. 2 0
      external/java-progressbar/.gitignore
  2. 1 0
      external/java-progressbar/.travis.yml
  3. 51 0
      external/java-progressbar/README.md
  4. 26 0
      external/java-progressbar/build.gradle
  5. 82 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/AbstractProgressBar.java
  6. 43 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/Progress.java
  7. 46 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/ProgressBar.java
  8. 193 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/console/ConsoleProgressBar.java
  9. 30 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/BarReplacer.java
  10. 18 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/ElapsedTimeReplacer.java
  11. 17 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/PercentageReplacer.java
  12. 22 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/RemainingTimeReplacer.java
  13. 9 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/Replacer.java
  14. 22 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/TotalTimeReplacer.java
  15. 7 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/helpers/Helper.java
  16. 65 0
      external/java-progressbar/src/main/java/hu/ssh/progressbar/helpers/HumanTimeFormatter.java
  17. 61 0
      external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/TestConsoleProgressBar.java
  18. 30 0
      external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestBarReplacer.java
  19. 31 0
      external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestElapsedTimeReplacer.java
  20. 30 0
      external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestPercentageReplacer.java
  21. 30 0
      external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestRemainingTimeReplacer.java
  22. 30 0
      external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestTotalTimeReplacer.java
  23. 29 0
      external/java-progressbar/src/test/java/hu/ssh/test/progressbar/helpers/TestHumanTimeFormatter.java
  24. 26 0
      external/java-progressbar/testng.xml
  25. 1 1
      iZpl/src/main/java/de/nplusc/izc/iZpl/CommandLineParsing.java
  26. 1 1
      settings.gradle

+ 2 - 0
external/java-progressbar/.gitignore

@@ -0,0 +1,2 @@
+/build
+/.gradle

+ 1 - 0
external/java-progressbar/.travis.yml

@@ -0,0 +1 @@
+language: java

+ 51 - 0
external/java-progressbar/README.md

@@ -0,0 +1,51 @@
+# ProgressBar
+
+This is a simple console progressbar for Java. It can be used in CLI programs
+to display progress for long tasks.
+
+It was born because I could not find a simple progress bar implementation
+for console based Java applications.
+
+The inspiration came from visionmedia's [node-progress][1].
+
+[![Build Status](https://secure.travis-ci.org/raszi/java-progressbar.png?branch=master)](http://travis-ci.org/raszi/java-progressbar)
+
+## Usage
+
+```java
+ProgressBar progressBar = ConsoleProgressBar.on(System.out);
+progressBar.tickOne();
+// do something
+progressBar.tick(25); // this will increase the percentage to 26
+// do the rest
+progerssBar.finish(); // this will finish it
+```
+
+### Example output
+
+```
+[==================================--------------------------]  57.00% 393ms
+```
+
+## Advanced configuration
+
+```java
+ProgressBar progressBar = ConsoleProgressBar.on(System.out)
+    .withFormat("[:bar] :percent% :elapsed/:total ETA: :eta")
+    .withTotalSteps(500);
+```
+
+## Available replacers for format
+
+ - `:bar` the progress bar
+ - `:elapsed` the elapsed time since the `start()` or the first `tick()`
+ - `:percent` the percentage without the percent sign
+ - `:eta` the estimated time to accomplish
+ - `:total` the total time to complete
+
+## TODOs
+
+ - it does not check whether the progressbar has been finished or not, so don't
+   call `finish()` more than once
+
+[1]: https://github.com/visionmedia/node-progress

+ 26 - 0
external/java-progressbar/build.gradle

@@ -0,0 +1,26 @@
+apply plugin: 'java'
+
+compileJava.options.encoding = 'UTF-8'
+
+repositories {
+	mavenCentral()
+}
+
+dependencies {
+	compile group: 'com.google.guava', name: 'guava', version: '19.0'
+	testCompile group: 'org.testng', name: 'testng', version: '6.9.10'
+}
+
+test {
+	useTestNG() {
+		suites 'testng.xml' 
+	}
+}
+
+uploadArchives {
+	repositories {
+		flatDir {
+			dirs 'repos'
+		}
+	}
+}

+ 82 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/AbstractProgressBar.java

@@ -0,0 +1,82 @@
+package hu.ssh.progressbar;
+
+public abstract class AbstractProgressBar<T extends AbstractProgressBar<?>> implements ProgressBar<T> {
+	protected final long totalSteps;
+
+	private long actualSteps = 0;
+	private long startTime = 0;
+
+	private long lastUpdate = 0;
+	private int lastUpdatePercent = 0;
+
+	protected AbstractProgressBar(final long totalSteps) {
+		this.totalSteps = totalSteps;
+	}
+
+	@Override
+	public final void start() {
+		refresh();
+	}
+
+	@Override
+	public final void tickOne() {
+		tick(1);
+	}
+
+	@Override
+	public final void tick(final long steps) {
+		setStartTimeIfNotStarted();
+
+		actualSteps += steps;
+
+		if (isRefreshNeeded()) {
+			refresh();
+		}
+	}
+
+	@Override
+	public final void refresh() {
+		setStartTimeIfNotStarted();
+
+		final Progress progress = getProgress();
+
+		lastUpdate = System.currentTimeMillis() / 1000;
+		lastUpdatePercent = (int) (progress.getPercentage() * 100);
+
+		updateProgressBar(progress);
+	}
+
+	@Override
+	public final void complete() {
+		setStartTimeIfNotStarted();
+
+		actualSteps = totalSteps;
+		refresh();
+	}
+
+	private Progress getProgress() {
+		return new Progress(totalSteps, actualSteps, System.currentTimeMillis() - startTime);
+	}
+
+	private void setStartTimeIfNotStarted() {
+		if (startTime == 0) {
+			startTime = System.currentTimeMillis();
+		}
+	}
+
+	private boolean isRefreshNeeded() {
+		if (lastUpdate != System.currentTimeMillis() / 1000) {
+			return true;
+		}
+
+		if (lastUpdatePercent != (int) (actualSteps * 100 / totalSteps)) {
+			return true;
+		}
+
+		return false;
+	}
+
+	protected abstract void updateProgressBar(final Progress progress);
+
+	protected abstract void finishProgressBar();
+}

+ 43 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/Progress.java

@@ -0,0 +1,43 @@
+package hu.ssh.progressbar;
+
+public class Progress {
+	private static final int MINIMAL_ELAPSED = 100;
+
+	private final long totalSteps;
+	private final long actualSteps;
+	private final long elapsedTime;
+
+	public Progress(final long totalSteps, final long actualSteps, final long elapsedTime) {
+		this.totalSteps = totalSteps;
+		this.actualSteps = actualSteps;
+		this.elapsedTime = elapsedTime;
+	}
+
+	public final long getTotalSteps() {
+		return totalSteps;
+	}
+
+	public final long getActualSteps() {
+		return actualSteps;
+	}
+
+	public final long getElapsedTime() {
+		return elapsedTime;
+	}
+
+	public final float getPercentage() {
+		return (float) actualSteps / totalSteps;
+	}
+
+	public final long getRemainingTime() {
+		return getTotalTime() - elapsedTime;
+	}
+
+	public final long getTotalTime() {
+		return (long) (elapsedTime / getPercentage());
+	}
+
+	public final boolean isRemainingTimeReliable() {
+		return elapsedTime > MINIMAL_ELAPSED;
+	}
+}

+ 46 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/ProgressBar.java

@@ -0,0 +1,46 @@
+package hu.ssh.progressbar;
+
+
+/**
+ * Defines the main interfaces to work with a progressbar.
+ *
+ * @author KARASZI István (github@spam.raszi.hu)
+ */
+public interface ProgressBar<T extends ProgressBar<?>> {
+	/**
+	 * Starts the progress bar.
+	 */
+	void start();
+
+	/**
+	 * Tick one step with the progressbar.
+	 */
+	void tickOne();
+
+	/**
+	 * Tick the specified steps with the progressbar.
+	 *
+	 * @param steps
+	 *            the specified steps
+	 */
+	void tick(long steps);
+
+	/**
+	 * Refresh the progressbar.
+	 */
+	void refresh();
+
+	/**
+	 * Finish the progressbar.
+	 */
+	void complete();
+
+	/**
+	 * Changes the total steps of the actual ProgressBar.
+	 * 
+	 * @param totalSteps
+	 *            the new total steps
+	 * @return a progress bar with the desired configuration
+	 */
+	T withTotalSteps(int totalSteps);
+}

+ 193 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/console/ConsoleProgressBar.java

@@ -0,0 +1,193 @@
+package hu.ssh.progressbar.console;
+
+import hu.ssh.progressbar.AbstractProgressBar;
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.console.replacers.BarReplacer;
+import hu.ssh.progressbar.console.replacers.ElapsedTimeReplacer;
+import hu.ssh.progressbar.console.replacers.PercentageReplacer;
+import hu.ssh.progressbar.console.replacers.RemainingTimeReplacer;
+import hu.ssh.progressbar.console.replacers.Replacer;
+import hu.ssh.progressbar.console.replacers.TotalTimeReplacer;
+
+import java.io.PrintStream;
+import java.util.Collection;
+import java.util.Set;
+
+import com.google.common.base.Preconditions;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * A console progress bar.
+ * <p>
+ * It can display a human readable progress bar with the specified format on the selected
+ * output.
+ * <p>
+ * Here is a basic usage:
+ *
+ * <pre>
+ * ProgressBar progressBar = ConsoleProgressBar.on(System.out);
+ * progressBar.tick(20);
+ * progressBar.finish();
+ * </pre>
+ *
+ * It can be configured with custom format:
+ *
+ * <pre>
+ * ProgressBar progressBar = ConsoleProgressBar.on(System.out)
+ * 		.withFormat(&quot;[:bar]&quot;);
+ * </pre>
+ *
+ * Or can be set to use custom number of steps instead of the default <code>100</code>:
+ *
+ * <pre>
+ * ProgressBar progressBar = ConsoleProgressBar.on(System.out)
+ * 		.withTotalSteps(25);
+ * </pre>
+ *
+ * @author KARASZI István (github@spam.raszi.hu)
+ */
+public final class ConsoleProgressBar extends AbstractProgressBar<ConsoleProgressBar> {
+	public static final char LINE_FEED = '\n';
+	public static final char CARRIAGE_RETURN = '\r';
+
+	public static final long DEFAULT_STEPS = 100;
+	public static final String DEFAULT_FORMAT = "[:bar] :percent% :eta";
+	public static final int DEFAULT_PROGRESSBAR_WIDTH = 60;
+	private static final Set<Replacer> DEFAULT_REPLACERS = getDefaultReplacers(DEFAULT_PROGRESSBAR_WIDTH);
+
+	private final Set<Replacer> replacers;
+	private final PrintStream streamToUse;
+	private final String outputFormat;
+
+	private int previousLength = 0;
+
+	private ConsoleProgressBar(
+			final PrintStream streamToUse,
+			final long totalSteps,
+			final String progressBarFormat,
+			final Set<Replacer> replacers)
+	{
+		super(totalSteps);
+
+		this.replacers = replacers;
+		this.streamToUse = streamToUse;
+		this.outputFormat = progressBarFormat;
+	}
+
+	/**
+	 * A console progress bar on the selected PrintStream.
+	 *
+	 * @param streamToUse
+	 *            the PrintStream on the ProgressBar should appear
+	 * @return a progress bar with the desired configuration
+	 */
+	public static ConsoleProgressBar on(final PrintStream streamToUse) {
+		Preconditions.checkNotNull(streamToUse);
+
+		return new ConsoleProgressBar(streamToUse,
+				DEFAULT_STEPS,
+				DEFAULT_FORMAT,
+				DEFAULT_REPLACERS);
+	}
+
+	/**
+	 * Changes the output format of the actual ProgressBar.
+	 *
+	 * @param outputFormat
+	 *            the new output format
+	 * @return a progress bar with the desired configuration
+	 */
+	public ConsoleProgressBar withFormat(final String outputFormat) {
+		Preconditions.checkNotNull(outputFormat);
+
+		return new ConsoleProgressBar(streamToUse,
+				totalSteps,
+				outputFormat,
+				replacers);
+	}
+
+	@Override
+	public ConsoleProgressBar withTotalSteps(final int totalSteps) {
+		Preconditions.checkArgument(totalSteps != 0);
+
+		return new ConsoleProgressBar(streamToUse,
+				totalSteps,
+				outputFormat,
+				replacers);
+	}
+
+	/**
+	 * Changes the replacers for the actual ProgressBar.
+	 *
+	 * @param replacers
+	 *            the new replacers to use
+	 * @return a progress bar with the desired configuration
+	 */
+	public ConsoleProgressBar withReplacers(final Collection<Replacer> replacers) {
+		Preconditions.checkNotNull(replacers);
+
+		return new ConsoleProgressBar(streamToUse,
+				totalSteps,
+				outputFormat,
+				ImmutableSet.copyOf(replacers));
+	}
+
+	/**
+	 * Gets the default replacers.
+	 *
+	 * @param progressBarWidth
+	 *            the width of the progress bar
+	 * @return the configured replacers
+	 */
+	public static Set<Replacer> getDefaultReplacers(final int progressBarWidth) {
+		return ImmutableSet.of(
+				new BarReplacer(progressBarWidth),
+				new PercentageReplacer(),
+				new RemainingTimeReplacer(),
+				new ElapsedTimeReplacer(),
+				new TotalTimeReplacer()
+				);
+	}
+
+	@Override
+	protected void updateProgressBar(final Progress progress) {
+		final String actualBar = getActualProgressBar(progress);
+
+		streamToUse.print(actualBar);
+		streamToUse.print(getGarbageCleaning(actualBar.length()));
+		streamToUse.print(CARRIAGE_RETURN);
+	}
+
+	@Override
+	protected void finishProgressBar() {
+		streamToUse.print(LINE_FEED);
+	}
+
+	private String getActualProgressBar(final Progress progress) {
+		String bar = outputFormat;
+
+		for (final Replacer replacer : replacers) {
+			final String identifier = replacer.getReplaceIdentifier();
+
+			if (!bar.contains(identifier)) {
+				continue;
+			}
+
+			bar = bar.replace(identifier, replacer.getReplacementForProgress(progress));
+		}
+
+		return bar;
+	}
+
+	private String getGarbageCleaning(final int actualLength) {
+		if (actualLength >= previousLength) {
+			return "";
+		}
+
+		final String garbageCleaner = Strings.repeat(" ", previousLength - actualLength);
+		previousLength = actualLength;
+
+		return garbageCleaner;
+	}
+}

+ 30 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/BarReplacer.java

@@ -0,0 +1,30 @@
+package hu.ssh.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+
+import com.google.common.base.Strings;
+
+public class BarReplacer implements Replacer {
+	private static final String IDENTIFIER = ":bar";
+	private static final String COMPLETED_CHAR = "=";
+	private static final char REMAINING_CHAR = '-';
+
+	private final int totalWidth;
+
+	public BarReplacer(final int totalWidth) {
+		this.totalWidth = totalWidth;
+	}
+
+	@Override
+	public final String getReplaceIdentifier() {
+		return IDENTIFIER;
+	}
+
+	@Override
+	public final String getReplacementForProgress(final Progress progress) {
+		final int actualWidth = (int) (progress.getPercentage() * totalWidth);
+
+		final String bar = Strings.repeat(COMPLETED_CHAR, actualWidth);
+		return Strings.padEnd(bar, totalWidth, REMAINING_CHAR);
+	}
+}

+ 18 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/ElapsedTimeReplacer.java

@@ -0,0 +1,18 @@
+package hu.ssh.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.helpers.HumanTimeFormatter;
+
+public class ElapsedTimeReplacer implements Replacer {
+	private static final String IDENTIFIER = ":elapsed";
+
+	@Override
+	public final String getReplaceIdentifier() {
+		return IDENTIFIER;
+	}
+
+	@Override
+	public final String getReplacementForProgress(final Progress progress) {
+		return HumanTimeFormatter.formatTime(progress.getElapsedTime());
+	}
+}

+ 17 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/PercentageReplacer.java

@@ -0,0 +1,17 @@
+package hu.ssh.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+
+public class PercentageReplacer implements Replacer {
+	private static final String IDENTIFIER = ":percent";
+
+	@Override
+	public final String getReplaceIdentifier() {
+		return IDENTIFIER;
+	}
+
+	@Override
+	public final String getReplacementForProgress(final Progress progress) {
+		return String.format("%6.2f", progress.getPercentage() * 100);
+	}
+}

+ 22 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/RemainingTimeReplacer.java

@@ -0,0 +1,22 @@
+package hu.ssh.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.helpers.HumanTimeFormatter;
+
+public class RemainingTimeReplacer implements Replacer {
+	private static final String IDENTIFIER = ":eta";
+
+	@Override
+	public final String getReplaceIdentifier() {
+		return IDENTIFIER;
+	}
+
+	@Override
+	public final String getReplacementForProgress(final Progress progress) {
+		if (!progress.isRemainingTimeReliable()) {
+			return "?";
+		}
+
+		return HumanTimeFormatter.formatTime(progress.getRemainingTime());
+	}
+}

+ 9 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/Replacer.java

@@ -0,0 +1,9 @@
+package hu.ssh.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+
+public interface Replacer {
+	String getReplaceIdentifier();
+
+	String getReplacementForProgress(Progress progress);
+}

+ 22 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/console/replacers/TotalTimeReplacer.java

@@ -0,0 +1,22 @@
+package hu.ssh.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.helpers.HumanTimeFormatter;
+
+public class TotalTimeReplacer implements Replacer {
+	private static final String IDENTIFIER = ":total";
+
+	@Override
+	public final String getReplaceIdentifier() {
+		return IDENTIFIER;
+	}
+
+	@Override
+	public final String getReplacementForProgress(final Progress progress) {
+		if (!progress.isRemainingTimeReliable()) {
+			return "?";
+		}
+
+		return HumanTimeFormatter.formatTime(progress.getTotalTime());
+	}
+}

+ 7 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/helpers/Helper.java

@@ -0,0 +1,7 @@
+package hu.ssh.progressbar.helpers;
+
+public class Helper {
+	protected Helper() {
+		throw new InstantiationError("Helper classes should not be instantiated");
+	}
+}

+ 65 - 0
external/java-progressbar/src/main/java/hu/ssh/progressbar/helpers/HumanTimeFormatter.java

@@ -0,0 +1,65 @@
+package hu.ssh.progressbar.helpers;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+
+public class HumanTimeFormatter extends Helper {
+	private static final List<DisplayUnit> DISPLAY_UNITS = ImmutableList.of(
+			DisplayUnit.of(TimeUnit.DAYS, "d"),
+			DisplayUnit.of(TimeUnit.HOURS, "h"),
+			DisplayUnit.of(TimeUnit.MINUTES, "m"),
+			DisplayUnit.of(TimeUnit.SECONDS, "s"),
+			DisplayUnit.of(TimeUnit.MILLISECONDS, "ms")
+			);
+
+	public static String formatTime(final long milliseconds) {
+		long diff = milliseconds;
+
+		final StringBuilder sb = new StringBuilder();
+
+		final Iterator<DisplayUnit> iterator = DISPLAY_UNITS.iterator();
+
+		while (iterator.hasNext()) {
+			final DisplayUnit displayUnit = iterator.next();
+
+			final long value = displayUnit.getFromMilliseconds(diff);
+
+			if (value != 0 || (!iterator.hasNext() && sb.length() == 0)) {
+				sb.append(displayUnit.getWithSuffix(value));
+				diff -= displayUnit.getInMilliseconds(value);
+			}
+		}
+
+		return sb.toString();
+	}
+
+	private static final class DisplayUnit {
+		private final TimeUnit timeUnit;
+		private final String suffix;
+
+		private DisplayUnit(final TimeUnit timeUnit, final String suffix) {
+			this.timeUnit = Preconditions.checkNotNull(timeUnit);
+			this.suffix = Preconditions.checkNotNull(suffix);
+		}
+
+		public static DisplayUnit of(final TimeUnit timeUnit, final String suffix) {
+			return new DisplayUnit(timeUnit, suffix);
+		}
+
+		public long getFromMilliseconds(final long milliseconds) {
+			return timeUnit.convert(milliseconds, TimeUnit.MILLISECONDS);
+		}
+
+		public long getInMilliseconds(final long value) {
+			return TimeUnit.MILLISECONDS.convert(value, timeUnit);
+		}
+
+		public String getWithSuffix(final long value) {
+			return String.format("%d%s", value, suffix);
+		}
+	}
+}

+ 61 - 0
external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/TestConsoleProgressBar.java

@@ -0,0 +1,61 @@
+package hu.ssh.test.progressbar.console;
+
+import hu.ssh.progressbar.console.ConsoleProgressBar;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Splitter;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+public class TestConsoleProgressBar {
+	private List<Object[]> getTestCases() {
+		return ImmutableList.of(
+				new Object[] { 0, "  0.00" },
+				new Object[] { 25, " 25.00" },
+				new Object[] { 30, " 55.00" },
+				new Object[] { 44, " 99.00" },
+				new Object[] { 1, "100.00" }
+				);
+	}
+
+	@Test
+	public final void testConsoleProgressBarOutput() throws IOException {
+		final ByteArrayOutputStream outputstream = new ByteArrayOutputStream();
+
+		try {
+			final ConsoleProgressBar progressBar = ConsoleProgressBar.on(new PrintStream(outputstream))
+					.withFormat(":percent");
+
+			for (final Object[] params : getTestCases()) {
+				final int nextTick = (Integer) params[0];
+				final String expectedOutput = (String) params[1];
+
+				progressBar.tick(nextTick);
+				Assert.assertEquals(getLastOutput(outputstream.toString()), expectedOutput);
+			}
+
+		} finally {
+			outputstream.close();
+		}
+	}
+
+	private String getLastOutput(final String string) {
+		if (Strings.isNullOrEmpty(string)) {
+			return string;
+		}
+
+		final Iterable<String> outputs = Splitter.on(ConsoleProgressBar.CARRIAGE_RETURN)
+				.omitEmptyStrings()
+				.split(string);
+
+		return Iterables.getLast(outputs);
+	}
+}

+ 30 - 0
external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestBarReplacer.java

@@ -0,0 +1,30 @@
+package hu.ssh.test.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.console.replacers.BarReplacer;
+
+import java.util.Iterator;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class TestBarReplacer {
+	@DataProvider
+	protected final Iterator<Object[]> getExampleBarContents() {
+		return ImmutableList.of(
+				new Object[] { new Progress(5, 0, 0), "-----" },
+				new Object[] { new Progress(5, 2, 0), "==---" },
+				new Object[] { new Progress(5, 3, 0), "===--" },
+				new Object[] { new Progress(5, 5, 0), "=====" }
+				).iterator();
+	}
+
+	@Test(dataProvider = "getExampleBarContents")
+	public final void testBarReplacer(final Progress progress, final String expectedContent) {
+		final BarReplacer replacer = new BarReplacer(5);
+		Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent);
+	}
+}

+ 31 - 0
external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestElapsedTimeReplacer.java

@@ -0,0 +1,31 @@
+package hu.ssh.test.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.console.replacers.ElapsedTimeReplacer;
+
+import java.util.Iterator;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class TestElapsedTimeReplacer {
+	@DataProvider
+	protected final Iterator<Object[]> getExampleTotalTimeContents() {
+		return ImmutableList.of(
+				new Object[] { new Progress(5, 0, 0), "0ms" },
+				new Object[] { new Progress(5, 2, 200), "200ms" },
+				new Object[] { new Progress(5, 3, 3000), "3s" },
+				new Object[] { new Progress(5, 5, 200), "200ms" }
+				).iterator();
+	}
+
+	@Test(dataProvider = "getExampleTotalTimeContents")
+	public final void testElapsedTimeReplacer(final Progress progress, final String expectedContent) {
+		final ElapsedTimeReplacer replacer = new ElapsedTimeReplacer();
+		Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent);
+	}
+}
+

+ 30 - 0
external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestPercentageReplacer.java

@@ -0,0 +1,30 @@
+package hu.ssh.test.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.console.replacers.PercentageReplacer;
+
+import java.util.Iterator;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class TestPercentageReplacer {
+	@DataProvider
+	protected final Iterator<Object[]> getExamplePercentageContents() {
+		return ImmutableList.of(
+				new Object[] { new Progress(5, 0, 0), "  0.00" },
+				new Object[] { new Progress(5, 2, 200), " 40.00" },
+				new Object[] { new Progress(5, 3, 3000), " 60.00" },
+				new Object[] { new Progress(5, 5, 200), "100.00" }
+				).iterator();
+	}
+
+	@Test(dataProvider = "getExamplePercentageContents")
+	public final void testPercentageReplacer(final Progress progress, final String expectedContent) {
+		final PercentageReplacer replacer = new PercentageReplacer();
+		Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent);
+	}
+}

+ 30 - 0
external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestRemainingTimeReplacer.java

@@ -0,0 +1,30 @@
+package hu.ssh.test.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.console.replacers.RemainingTimeReplacer;
+
+import java.util.Iterator;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class TestRemainingTimeReplacer {
+	@DataProvider
+	protected final Iterator<Object[]> getExampleRemainingTimeContents() {
+		return ImmutableList.of(
+				new Object[] { new Progress(5, 0, 0), "?" },
+				new Object[] { new Progress(5, 2, 200), "300ms" },
+				new Object[] { new Progress(5, 3, 3000), "2s" },
+				new Object[] { new Progress(5, 5, 200), "0ms" }
+				).iterator();
+	}
+
+	@Test(dataProvider = "getExampleRemainingTimeContents")
+	public final void testRemaingingTimeReplacer(final Progress progress, final String expectedContent) {
+		final RemainingTimeReplacer replacer = new RemainingTimeReplacer();
+		Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent);
+	}
+}

+ 30 - 0
external/java-progressbar/src/test/java/hu/ssh/test/progressbar/console/replacers/TestTotalTimeReplacer.java

@@ -0,0 +1,30 @@
+package hu.ssh.test.progressbar.console.replacers;
+
+import hu.ssh.progressbar.Progress;
+import hu.ssh.progressbar.console.replacers.TotalTimeReplacer;
+
+import java.util.Iterator;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class TestTotalTimeReplacer {
+	@DataProvider
+	protected final Iterator<Object[]> getExampleTotalTimeContents() {
+		return ImmutableList.of(
+				new Object[] { new Progress(5, 0, 0), "?" },
+				new Object[] { new Progress(5, 2, 200), "500ms" },
+				new Object[] { new Progress(5, 3, 3000), "5s" },
+				new Object[] { new Progress(5, 5, 200), "200ms" }
+				).iterator();
+	}
+
+	@Test(dataProvider = "getExampleTotalTimeContents")
+	public final void testTotalTimeReplacer(final Progress progress, final String expectedContent) {
+		final TotalTimeReplacer replacer = new TotalTimeReplacer();
+		Assert.assertEquals(replacer.getReplacementForProgress(progress), expectedContent);
+	}
+}

+ 29 - 0
external/java-progressbar/src/test/java/hu/ssh/test/progressbar/helpers/TestHumanTimeFormatter.java

@@ -0,0 +1,29 @@
+package hu.ssh.test.progressbar.helpers;
+
+import hu.ssh.progressbar.helpers.HumanTimeFormatter;
+
+import java.util.Iterator;
+
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+
+public class TestHumanTimeFormatter {
+	@DataProvider
+	public final Iterator<Object[]> getExampleConversions() {
+		return ImmutableList.of(
+				new Object[] { 0L, "0ms" },
+				new Object[] { 150L, "150ms" },
+				new Object[] { 6005L, "6s5ms" },
+				new Object[] { 600001L, "10m1ms" },
+				new Object[] { 5061616105L, "58d14h16s105ms" }
+				).iterator();
+	}
+
+	@Test(dataProvider = "getExampleConversions")
+	public final void testConversion(final long elapsedTime, final String expectedOutput) {
+		Assert.assertEquals(HumanTimeFormatter.formatTime(elapsedTime), expectedOutput);
+	}
+}

+ 26 - 0
external/java-progressbar/testng.xml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+<suite name="ProgressBar Suite" parallel="classes" thread-count="10" verbose="2">
+	<test name="Helpers">
+		<classes>
+			<class name="hu.ssh.test.progressbar.helpers.TestHumanTimeFormatter" />
+		</classes>
+	</test>
+
+	<test name="Console replacers">
+		<classes>
+			<class name="hu.ssh.test.progressbar.console.replacers.TestBarReplacer" />
+			<class name="hu.ssh.test.progressbar.console.replacers.TestElapsedTimeReplacer" />
+			<class name="hu.ssh.test.progressbar.console.replacers.TestPercentageReplacer" />
+			<class name="hu.ssh.test.progressbar.console.replacers.TestRemainingTimeReplacer" />
+			<class name="hu.ssh.test.progressbar.console.replacers.TestTotalTimeReplacer" />
+		</classes>
+	</test>
+
+	<test name="Console">
+		<classes>
+			<class name="hu.ssh.test.progressbar.console.TestConsoleProgressBar" />
+		</classes>
+	</test>
+
+</suite>

+ 1 - 1
iZpl/src/main/java/de/nplusc/izc/iZpl/CommandLineParsing.java

@@ -76,7 +76,7 @@ public class CommandLineParsing
                 .withDescription("enables External VLC Player UIMode. Starts program straight if --file or --resume is set")
                 .create("o"));
         options.addOption("p", "pregen", false, "Pregens a standalone playlist with the randomisation included. Use togehter only with --file");
-        options.addOption("v", "verbose", false, "Enables verbose VLCJ logging");
+        options.addOption("v", "verbose", false, "Enables verbose logging");
         
         
         options.addOption(OptionBuilder.withLongOpt("pluginparameter")

+ 1 - 1
settings.gradle

@@ -1,3 +1,3 @@
 include 'ToolKit','iZpl',  'IZSetup','WPCMgr','UpidTK', 'izstreamer', 'LogBlockHeatMapper','iZlaunch',
 'iZpaqSFX','MazeViewer','TWPUtil',"iZplPlugins:WMP","iZplPlugins:foobar2000_others","iZplPlugins:itunes","iZplPlugins:GameRadio",
-"iZplPlugins:Editor","izpl-shared","iZpl-server","iZplPlugins:Smartphonizer","QuickStuff"
+"iZplPlugins:Editor","izpl-shared","iZpl-server","iZplPlugins:Smartphonizer","QuickStuff","external:java-progressbar"