From 57046ac1142998cd9906610af2c30f95b9e8cd90 Mon Sep 17 00:00:00 2001 From: Tongfei Chen Date: Sun, 24 Mar 2024 00:19:33 -0700 Subject: [PATCH] setRenderer ;0.10.1 --- CHANGELOG.md | 4 ++++ LICENSE | 2 +- docs/index.md | 6 +++-- mkdocs.yml | 4 +++- pom.xml | 24 ++++++++++++++++++- .../progressbar/ProgressBarBuilder.java | 9 ++++++- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d99fc4..a2ac24c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog + * `0.10.1`: + - Improvements: + - Changed the JPMS module dependency `org.jline` to a more fine-grained module `org.jline.terminal` (#158, PR #159). Thanks @brett-smith ! + - Added a new builder method `setRenderer` to allow custom renderers (#157). Thanks @drothmaler ! * `0.10.0`: - New functionalities: - Make `me.tongfei.progressbar` a Java 9 module (#149, #153, #154). Thanks @clo-vis, @Kamillaova, @bowbahdoe ! diff --git a/LICENSE b/LICENSE index afb16b3..4a58ef9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015--2020 Tongfei Chen and contributors +Copyright (c) 2015--2024 Tongfei Chen and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/docs/index.md b/docs/index.md index fc862c6..d96581d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,16 +12,18 @@ Depending on your build tool, add the following setting. me.tongfei progressbar - 0.10.0 + $VERSION ``` === "Gradle" ``` groovy - compile 'me.tongfei:progressbar:0.10.0' + compile 'me.tongfei:progressbar:$VERSION' ``` +The newest `$VERSION` is [![Maven Central](https://img.shields.io/maven-central/v/me.tongfei/progressbar.svg?style=flat-square)](https://maven-badges.herokuapp.com/maven-central/me.tongfei/progressbar). + #### Getting started ``` java diff --git a/mkdocs.yml b/mkdocs.yml index ba513c7..0017b9e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,7 +1,7 @@ site_name: 'Progressbar' site_description: 'A terminal progress bar for Java/JVM' site_author: 'Tongfei Chen' -copyright: 'Copyright © 2015-2023 Tongfei Chen and contributors' +copyright: 'Copyright © 2015-2024 Tongfei Chen and contributors' theme: name: 'material' @@ -37,3 +37,5 @@ nav: - 'Kotlin extensions': 'kotlin.md' - 'Integrating with loggers': 'loggers.md' - 'Changelog': 'changelog.md' + - 'API Docs': + - 'index': 'dokka-javadoc/index.html' \ No newline at end of file diff --git a/pom.xml b/pom.xml index 698d6a0..4602d06 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.tongfei progressbar - 0.10.0 + 0.10.1 progressbar A terminal-based progress bar for JVM http://github.com/ctongfei/progressbar @@ -266,6 +266,28 @@ false + + org.jetbrains.dokka + dokka-maven-plugin + 1.9.10 + + + pre-site + + dokka + + + + + + + org.jetbrains.dokka + javadoc-plugin + 1.9.10 + + + + diff --git a/src/main/java/me/tongfei/progressbar/ProgressBarBuilder.java b/src/main/java/me/tongfei/progressbar/ProgressBarBuilder.java index 6dabdf8..6eb2c53 100644 --- a/src/main/java/me/tongfei/progressbar/ProgressBarBuilder.java +++ b/src/main/java/me/tongfei/progressbar/ProgressBarBuilder.java @@ -31,6 +31,8 @@ public class ProgressBarBuilder { private Duration elapsed = Duration.ZERO; private int maxRenderedLength = -1; + private ProgressBarRenderer renderer = null; + public ProgressBarBuilder() { } public ProgressBarBuilder setTaskName(String task) { @@ -83,6 +85,11 @@ public ProgressBarBuilder setMaxRenderedLength(int maxRenderedLength) { return this; } + public ProgressBarBuilder setRenderer(ProgressBarRenderer renderer) { + this.renderer = renderer; + return this; + } + public ProgressBarBuilder showSpeed() { return showSpeed(new DecimalFormat("#.0")); } @@ -129,7 +136,7 @@ public ProgressBar build() { clearDisplayOnFinish, processed, elapsed, - new DefaultProgressBarRenderer( + renderer == null ? new DefaultProgressBarRenderer( style, unitName, unitSize, showSpeed, speedFormat, speedUnit, !hideEta, eta),