Compare commits

...

8 Commits

5 changed files with 41 additions and 23 deletions

2
.gitignore vendored
View File

@@ -1 +1,3 @@
target/
deploy/
*.class

View File

@@ -1,4 +1,8 @@
#!/usr/bin/env bash
set -uo pipefail
javac -Xlint -d target/ src/**/*.java
if [[ $# -ge 1 && $1 == "clean" ]]; then
rm -r target/;
fi
javac -Xlint -d target/ src/**/*.java;

View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -uo pipefail
if [[ -d deploy/ ]]; then
rm -r deploy/;
fi
cp -r target/ deploy/;

View File

@@ -74,7 +74,7 @@ public abstract class AbstractLoadingBar {
}
public long getPassedMinutes() {
public final long getPassedMinutes() {
return getPassedMinutes(false);
}
@@ -84,37 +84,37 @@ public abstract class AbstractLoadingBar {
}
public void showLoadingBar() {
showLoadingBar(false, false, 0);
public final void showLoadingBar() {
realShowLoadingBar(false, false, 0);
}
public void showLoadingBar(boolean debug, boolean passedMinutesZero) {
showLoadingBar(debug, passedMinutesZero, 100L);
public final void showLoadingBar(boolean debug, boolean passedMinutesZero) {
realShowLoadingBar(debug, passedMinutesZero, 100L);
}
public void showLoadingBarDebug() {
showLoadingBar(true, true, 100L);
public final void showLoadingBarDebug() {
realShowLoadingBar(true, true, 100L);
}
public void showLoadingBarDebug(long millisWaiting) {
showLoadingBar(true, true, millisWaiting);
public final void showLoadingBarDebug(long millisWaiting) {
realShowLoadingBar(true, true, millisWaiting);
}
public void showLoadingBarDebug(boolean passedMinutesZero) {
showLoadingBar(true, passedMinutesZero, 100L);
public final void showLoadingBarDebug(boolean passedMinutesZero) {
realShowLoadingBar(true, passedMinutesZero, 100L);
}
public void showLoadingBarDebug(boolean passedMinutesZero, long millisWaiting) {
showLoadingBar(true, passedMinutesZero, millisWaiting);
public final void showLoadingBarDebug(boolean passedMinutesZero, long millisWaiting) {
realShowLoadingBar(true, passedMinutesZero, millisWaiting);
}
private void showLoadingBar(boolean debug, boolean passedMinutesZero, long millisWaiting) {
private void realShowLoadingBar(boolean debug, boolean passedMinutesZero, long millisWaiting) {
long passedMinutes = getPassedMinutes(debug && passedMinutesZero);
if (passedMinutes > totalMinutes) {
passedMinutes = totalMinutes;
@@ -129,23 +129,27 @@ public abstract class AbstractLoadingBar {
passedMinutes++;
}
println(fillLoadingBar(passedMinutes, false));
afterShowLoadingBar();
}
protected abstract String fillLoadingBar(long passedMinutes, boolean progressive);
protected void waitUntilNextMinute() {
protected void afterShowLoadingBar() {}
protected final void waitUntilNextMinute() {
waitUntilNextMinute(false, 0L);
}
protected void waitUntilNextMinuteDebug() {
protected final void waitUntilNextMinuteDebug() {
waitUntilNextMinute(true, 100L);
}
protected void waitUntilNextMinuteDebug(long millisWaiting) {
protected final void waitUntilNextMinuteDebug(long millisWaiting) {
waitUntilNextMinute(true, millisWaiting);
}

View File

@@ -45,14 +45,16 @@ public class SimpleLoadingBar extends AbstractProgressBar {
} else {
startTime = firstTime;
}
boolean debug = false;
boolean passedMinutesZero = false;
if (args.length == 2 || !title.isBlank()) {
new SimpleLoadingBar(startTime, endTime, title).showLoadingBar();
new SimpleLoadingBar(startTime, endTime, title).showLoadingBar(debug, passedMinutesZero);
return;
}
// if there are 3 arguments, the third will be discarded.
boolean hasTitleArg = args.length > 3 && "-msg".equals(args[2]);
title = hasTitleArg ? args[3] : title;
new SimpleLoadingBar(startTime, endTime, title).showLoadingBar();
new SimpleLoadingBar(startTime, endTime, title).showLoadingBar(debug, passedMinutesZero);
}
@@ -94,9 +96,7 @@ public class SimpleLoadingBar extends AbstractProgressBar {
@Override
public void showLoadingBar() {
super.showLoadingBar();
// showLoadingBarDebug(); // DEBUG
protected void afterShowLoadingBar() {
println(title);
}
}