Fixed access modifiers for Java version.
This commit is contained in:
parent
281e52c797
commit
42eb01d5f8
45
README.md
Normal file
45
README.md
Normal 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)
|
||||||
|
```
|
@ -2,7 +2,7 @@ apply plugin: "groovy"
|
|||||||
apply plugin: "maven"
|
apply plugin: "maven"
|
||||||
|
|
||||||
group = "com.jdbernard"
|
group = "com.jdbernard"
|
||||||
version = "1.0"
|
version = "1.1"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "1.0"
|
version = "1.1"
|
||||||
author = "Jonathan Bernard"
|
author = "Jonathan Bernard"
|
||||||
description = "Utility for writing dynamic progress bars to the console."
|
description = "Utility for writing dynamic progress bars to the console."
|
||||||
license = "BSD"
|
license = "BSD"
|
||||||
|
Binary file not shown.
@ -8,7 +8,7 @@ package com.jdbernard.util
|
|||||||
* counter is 1-based because the current step is complete for this counter.
|
* counter is 1-based because the current step is complete for this counter.
|
||||||
* @author Jonathan Bernard (jdbernard@gmail.com)
|
* @author Jonathan Bernard (jdbernard@gmail.com)
|
||||||
*/
|
*/
|
||||||
class ConsoleProgressBar {
|
public class ConsoleProgressBar {
|
||||||
int MAX_STEP = 30
|
int MAX_STEP = 30
|
||||||
|
|
||||||
long max = 10
|
long max = 10
|
||||||
@ -21,7 +21,7 @@ class ConsoleProgressBar {
|
|||||||
public void setMax(long max) {
|
public void setMax(long max) {
|
||||||
this.max = Math.max(max, 1) }
|
this.max = Math.max(max, 1) }
|
||||||
|
|
||||||
void update(long value, String info) {
|
public void update(long value, String info) {
|
||||||
if (value == 0 || startTime == 0)
|
if (value == 0 || startTime == 0)
|
||||||
startTime = System.currentTimeMillis()
|
startTime = System.currentTimeMillis()
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ class ConsoleProgressBar {
|
|||||||
out.flush()
|
out.flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
void erase() {
|
public void erase() {
|
||||||
out.print '\b' * lastLinePrinted.length()
|
out.print '\b' * lastLinePrinted.length()
|
||||||
out.print ' ' * lastLinePrinted.length()
|
out.print ' ' * lastLinePrinted.length()
|
||||||
out.print '\b' * lastLinePrinted.length()
|
out.print '\b' * lastLinePrinted.length()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user