-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bff06f6
Showing
10 changed files
with
472 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.settings* | ||
.idea/* | ||
.project | ||
.credentials* | ||
gfx/* | ||
PublicHtml/* | ||
node_modules* | ||
.tmp* | ||
intern_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
### 1.0.0 ### | ||
Initial public release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
Contribution | ||
------------ | ||
|
||
CLI-Progress is OpenSource and managed on [GitHub](https://github.com/AndiDittrich/Node.CLI-Progress) - if you like, you're welcome to contribute! | ||
To simplify the release and quality control process, please follow these remarks: | ||
|
||
### Notices ### | ||
* Related software packages are updated by the maintainer | ||
* If you form a concept of larger project changes, please [discuss](https://github.com/AndiDittrich/Node.CLI-Progress/issues) them with the contributors **before** implementing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
The MIT License (X11 License) | ||
|
||
Copyright (c) 2015 Andi Dittrich | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the "Software"), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
CLI-Progress | ||
============ | ||
Easy to use Progress-Bar for Command-Line/Terminal Applications | ||
|
||
Features | ||
-------- | ||
|
||
* Simple, Robust and easily to use | ||
* Full customizable output format (various placeholders are available= | ||
* Custom Bar Characters | ||
* FPS limiter | ||
* ETA calculation based on elapsed time | ||
* Only visible in TTY environments | ||
* No callbacks required - designed as pure, external controlled UI widget | ||
|
||
*Successful tested on Windows10, Debian 8.2 and Ubuntu 14 LTS* | ||
|
||
Installation | ||
------------ | ||
|
||
You can install cli-progress with [NPM](http://npmjs.com) | ||
|
||
```bash | ||
$ npm install cli-progress | ||
``` | ||
|
||
Or manually from the [GitHub Repository](https://github.com/AndiDittrich/Node.CLI-Progress/releases/latest) | ||
|
||
```bash | ||
$ wget https://github.com/AndiDittrich/Node.CLI-Progress/archive/v1.0.0.tar.gz | ||
``` | ||
|
||
Progress-Bar | ||
------------ | ||
|
||
### Usage ### | ||
|
||
```js | ||
var _progress = require('cli-progress'); | ||
|
||
// create a new progress bar instance | ||
var bar1 = new _progress.Bar(); | ||
|
||
// start the progress bar with a total value of 200 and start value of 0 | ||
bar1.start(200, 0); | ||
|
||
// update the current value in your application.. | ||
bar1.update(100); | ||
|
||
// stop the progress bar | ||
bar1.stop(); | ||
``` | ||
|
||
### Methods/Syntax ### | ||
|
||
#### Constructor #### | ||
|
||
Initialize a new Progress bar. An instance can be used **multiple** times! it's not required to re-create it! | ||
|
||
```js | ||
var <instance> = new namespace.Bar(options:object); | ||
``` | ||
|
||
#### start() #### | ||
|
||
Starts the progress bar and set the total and initial value | ||
|
||
```js | ||
<instance>.start(totalValue:int, startValue:int); | ||
``` | ||
|
||
#### update() #### | ||
|
||
Sets the current progress value | ||
|
||
```js | ||
<instance>.update(currentValue:int); | ||
``` | ||
|
||
#### stop() #### | ||
|
||
Stops the progress bar and go to next line | ||
|
||
```js | ||
<instance>.stop(); | ||
``` | ||
|
||
|
||
### Bar Formatting ### | ||
|
||
The progressbar can be customized by using the following build-in placeholders. They can be combined in any order. | ||
|
||
- **{bar}** - the progress bar, customizable by the options **barsize**, **barCompleteString** and **barIncompleteString** | ||
- **{percentage}** - the current progress in percent (0-100) | ||
- **{total}** - the end value | ||
- **{value}** - the current value set by last `update()` call | ||
- **{eta}** - expected time of accomplishment in seconds | ||
- **{duration}** - elapsed time in seconds | ||
|
||
#### Example #### | ||
|
||
``` | ||
progess [{bar}] {percentage}% | ETA: {eta}s | {value}/{total} | ||
``` | ||
|
||
is rendered as | ||
|
||
``` | ||
progess [========================================] 100% | ETA: 0s | 200/200 | ||
``` | ||
|
||
### Options ### | ||
|
||
- **format** (type:string) - progress bar output format @see format section | ||
- **fps** (type:int) - the maximum update rate | ||
- **stream** (type:stream) - output stream to use (default: `process.stderr`) | ||
- **clearOnComplete** (type:boolean) - clear the progress bar on complete - `stop()` called (default: false) | ||
- **barsize** (type:int) - the length of the progress bar in chars (default: 40) | ||
- **barCompleteString** (type:char) - character to use as "complete" indicator in the bar (default: "=") | ||
- **barIncompleteString** (type:char) - character to use as "incomplete" indicator in the bar (default: "-") | ||
|
||
#### Example #### | ||
|
||
```js | ||
// change the progress characters | ||
// set fps limit to 5 | ||
// change the output stream and barsize | ||
var b2 = new _progress.Bar({ | ||
barCompleteChar: '#', | ||
barIncompleteChar: '.', | ||
fps: 5, | ||
stream: process.stdout, | ||
barsize: 65 | ||
}); | ||
``` | ||
|
||
Any Questions ? Report a Bug ? Enhancements ? | ||
--------------------------------------------- | ||
Please open a new issue on [GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues) | ||
|
||
License | ||
------- | ||
CLI-Progress is OpenSource and licensed under the Terms of [The MIT License (X11)](http://opensource.org/licenses/MIT). You're welcome to [contribute](https://github.com/AndiDittrich/Node.CLI-Progress/blob/master/CONTRIBUTE.md)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
var _progress = require('./main'); | ||
var color = require('colors'); | ||
|
||
// run the example sequentially! otherwise both will write to stdout/stderr simultaneous ! | ||
Example1(function(){ | ||
Example2(function(){ | ||
console.log('\nDemo finished!'); | ||
}); | ||
}); | ||
|
||
function Example1(onComplete){ | ||
// EXAMPLE 1 --------------------------------------------- | ||
console.log('\nExample 1 - Standard configuration'); | ||
// create new progress bar using default values | ||
var b1 = new _progress.Bar(); | ||
b1.start(200, 0); | ||
|
||
// the bar value - will be linear incremented | ||
var value = 0; | ||
|
||
// 20ms update rate | ||
var timer = setInterval(function(){ | ||
// increment value | ||
value++; | ||
|
||
// update the bar value | ||
b1.update(value) | ||
|
||
// set limit | ||
if (value >= b1.getTotal()){ | ||
// stop timer | ||
clearInterval(timer); | ||
|
||
b1.stop(); | ||
|
||
// run complete callback | ||
onComplete.apply(this); | ||
} | ||
}, 20); | ||
} | ||
|
||
|
||
function Example2(onComplete){ | ||
// EXAMPLE 2 --------------------------------------------- | ||
console.log('\nExample 2 - Custom configuration & colorized'); | ||
|
||
// create new progress bar using default values | ||
var b2 = new _progress.Bar({ | ||
barCompleteChar: '#', | ||
barIncompleteChar: '.', | ||
format: color.yellow(' |- Current Upload Progress: {percentage}%') + ' - ' + color.grey('||{bar}||'), | ||
fps: 5, | ||
stream: process.stdout, | ||
barsize: 65 | ||
}); | ||
b2.start(100, 0); | ||
|
||
// the bar value - will be linear incremented | ||
var value = 0; | ||
|
||
// 50ms update rate | ||
var timer = setInterval(function(){ | ||
// increment value | ||
value++; | ||
|
||
// update the bar value | ||
b2.update(value) | ||
|
||
// set limit | ||
if (value >= b2.getTotal()){ | ||
// stop timer | ||
clearInterval(timer); | ||
|
||
b2.stop(); | ||
|
||
// run complete callback | ||
onComplete.apply(this); | ||
} | ||
}, 50); | ||
}; |
Oops, something went wrong.