JFortschritt
JFortschritt is a small library for writing progress bars to the command-line.
JFortschritt is published under the MIT license. It needs Java 7, because this is the version that is supported by most applications that I encounter. Please let me know if you need JFortschritt to support an older version of Java.
Installation
JFortschritt is available from Maven Central.
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>jfortschritt</artifactId>
<version>0.2.0</version>
</dependency>
Usage
Currently the library provides a single class: the ProgressLine
. First create a new progress line.
import com.github.stefanbirkner.jfortschritt.*;
...
ProgressLine progressLine = new ProgressLine();
Start the progress line with the number of steps that are needed for completion:
progressLine.startWithNumberOfSteps(42);
It immediately prints an empty progress bar and a counter:
[> ]
The width of the line is always 72 chars. Now move the progress line forward.
progressLine.moveForward();
and see the result
[==> ]
This is how a progress line looks at the end. (It renders a new line character, too. Thus additional text starts at a new line.)
[=====================================================================>]
You may add additional parts to the progress line. E.g. JFortschritt provides a counter and a part with the estimated time, but you can build your own parts by implementing the interface ProgressLinePart
.
ProgressLine progressLine = new ProgressLine(
new Counter(), new EstimatedTime());
This is how a progress line looks with the additional parts.
[==> ] (1/42) eta 10s
Contributing
You have three options if you have a feature request, found a bug or simply have a question about JFortschritt.
- Write an issue.
- Create a pull request. (See Understanding the GitHub Flow)
- Write an email to [email protected]
Development Guide
JFortschritt is build with Maven. If you want to contribute code than
- Please write a test for your change.
- Ensure that you didn't break the build by running
mvn test
. - Fork the repo and create a pull request. (See Understanding the GitHub Flow)
The basic coding style is described in the EditorConfig file .editorconfig
.
JFortschritt supports Travis CI for continuous integration. Your pull request will be automatically build by Travis CI.
Release Guide
- Select a new version according to the Semantic Versioning 2.0.0 Standard.
- Set the new version in
pom.xml
and in theInstallation
section of this readme. - Commit the modified
pom.xml
andREADME.md
. - Run
mvn clean deploy
with JDK 7. - Add a tag for the release:
git tag jfortschritt-X.X.X