Skip to content

Commit

Permalink
Move demo out of production code
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakambda committed Sep 12, 2024
1 parent 61763b8 commit fafe563
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 6 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ tasks {
}
}

tasks.register<JavaExec>("rrun") {
classpath = sourceSets.main.get().runtimeClasspath
mainClass = "fr.rakambda.progressbar.Main"
mainModule = "fr.rakambda.progressbar"
tasks.register<Test>("demo") {
useJUnitPlatform()
group = "demo"
filter {
includeTestsMatching("fr.rakambda.progressbar.ShowcaseDemo.run")
}
}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public String render(int maxLength, @NotNull IProgressBar bar){
prefix.append(' ');
}
if(bar.isShowPercentage()){
prefix.append("%d%%".formatted((int) (progress * 100)));
prefix.append("%3d%%".formatted((int) (progress * 100)));
prefix.append(' ');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
import fr.rakambda.progressbar.impl.bar.CumulativeProgressBar;
import fr.rakambda.progressbar.impl.bar.SimpleProgressBar;
import fr.rakambda.progressbar.impl.holder.ProgressBarHolder;
import org.junit.jupiter.api.Test;
import java.util.LinkedList;
import java.util.concurrent.atomic.AtomicLong;

public class Main{
public static void main(String[] args) throws Exception{
@SuppressWarnings("NewClassNamingConvention")
class ShowcaseDemo {
@Test
void run() throws Exception{
try(var holder = ProgressBarHolder.builder().build()){
var composedBar = holder.addProgressBar(CumulativeProgressBar.builder()
.name("group-task-1")
Expand All @@ -26,6 +29,7 @@ public static void main(String[] args) throws Exception{
.name("test-" + i)
.end(new AtomicLong(100))
.hideWhenComplete(true)
.description("desc")
.unit("ut")
.build()));
}
Expand Down

0 comments on commit fafe563

Please sign in to comment.