2 Commits
1.0 ... 1.1

Author SHA1 Message Date
5f7cbeae92 Updated license file. 2016-01-25 15:13:51 -06:00
42eb01d5f8 Fixed access modifiers for Java version. 2016-01-25 15:13:21 -06:00
6 changed files with 52 additions and 7 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2014
Copyright (c) 2016
All rights reserved.
Redistribution and use in source and binary forms, with or without
@ -24,4 +24,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

45
README.md Normal file
View File

@ -0,0 +1,45 @@
# Console Progress Bar
Simple progress bar for long-running operations.
## Java/Groovy
Build with gradle:
gradle assemble
Example usage:
```java
import com.jdbernard.util.ConsoleProgressBar
// ...
ConsoleProgressBar progressBar = new ConsoleProgressBar()
progressBar.setOut(System.out) // optional
progressBar.setMax(100)
for (int i = 0; i <= 100; i++) {
progressBar.update(i, "Message for " + i);
Thread.sleep(500);
}
```
## Nim
Install the library using nimble:
nimble install
Example usage:
```nim
import os, console_progress
var progress = newProgress(sout = stdout, maxValue = 100)
for i in 0..100:
progress.updateProgress(i, "Message for " & i)
sleep(500)
```

View File

@ -2,7 +2,7 @@ apply plugin: "groovy"
apply plugin: "maven"
group = "com.jdbernard"
version = "1.0"
version = "1.1"
repositories {
mavenLocal()

View File

@ -1,6 +1,6 @@
# Package
version = "1.0"
version = "1.1"
author = "Jonathan Bernard"
description = "Utility for writing dynamic progress bars to the console."
license = "BSD"

View File

@ -8,7 +8,7 @@ package com.jdbernard.util
* counter is 1-based because the current step is complete for this counter.
* @author Jonathan Bernard (jdbernard@gmail.com)
*/
class ConsoleProgressBar {
public class ConsoleProgressBar {
int MAX_STEP = 30
long max = 10
@ -21,7 +21,7 @@ class ConsoleProgressBar {
public void setMax(long max) {
this.max = Math.max(max, 1) }
void update(long value, String info) {
public void update(long value, String info) {
if (value == 0 || startTime == 0)
startTime = System.currentTimeMillis()
@ -60,7 +60,7 @@ class ConsoleProgressBar {
out.flush()
}
void erase() {
public void erase() {
out.print '\b' * lastLinePrinted.length()
out.print ' ' * lastLinePrinted.length()
out.print '\b' * lastLinePrinted.length()