cli-progress
Advanced tools
Comparing version 3.0.0 to 3.1.0
## Branch 3.x ## | ||
### 3.1.0 ### | ||
* Added: notty support (interval/schedule based output) - feature requested [on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/25) | ||
* Added: `stopOnComplete` support within `MultiBar` - thanks to [Nox-404 on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/pull/35) | ||
* Changed: initial throttel time of `MultiBar` is controlled by `fps` option instead of static `500ms` value | ||
* Bugfix: provided option didn't take precedence over the preset as in v2 - thanks to [AxelTerizaki on GitHub](https://github.com/AndiDittrich/Node.CLI-Progress/issues/37) #37 | ||
### 3.0.0 ### | ||
@@ -4,0 +11,0 @@ |
@@ -115,3 +115,4 @@ const _ETA = require('./eta'); | ||
// string changed ? only trigger redraw on change! | ||
if (this.lastDrawnString != s){ | ||
// force redraw in notty-mode! | ||
if (this.lastDrawnString != s || (this.options.noTTYOutput && !this.terminal.isTTY())){ | ||
// set cursor to start of line | ||
@@ -118,0 +119,0 @@ this.terminal.cursorTo(0, null); |
@@ -26,2 +26,5 @@ const _Terminal = require('./terminal'); | ||
this.isActive = false; | ||
// update interval | ||
this.schedulingRate = (this.terminal.isTTY() ? this.options.throttleTime : this.options.notTTYSchedule); | ||
} | ||
@@ -31,2 +34,7 @@ | ||
create(total, startValue, payload){ | ||
// progress updates are only visible in TTY mode! | ||
if (this.options.noTTYOutput === false && this.terminal.isTTY() === false){ | ||
return; | ||
} | ||
// create new bar element | ||
@@ -54,3 +62,3 @@ const bar = new _BarElement(this.options); | ||
// initialize update timer | ||
this.timer = setTimeout(this.update.bind(this), 500); | ||
this.timer = setTimeout(this.update.bind(this), this.schedulingRate); | ||
} | ||
@@ -113,4 +121,15 @@ | ||
// add new line in notty mode! | ||
if (this.options.noTTYOutput && this.terminal.isTTY() === false){ | ||
this.terminal.newline(); | ||
this.terminal.newline(); | ||
} | ||
// next update | ||
this.timer = setTimeout(this.update.bind(this), this.options.throttleTime); | ||
this.timer = setTimeout(this.update.bind(this), this.schedulingRate); | ||
// stop if stopOnComplete and all bars stopped | ||
if (this.options.stopOnComplete && !this.bars.find(bar => bar.isActive)) { | ||
this.stop(); | ||
} | ||
} | ||
@@ -168,2 +187,2 @@ | ||
} | ||
} | ||
} |
@@ -18,3 +18,3 @@ // global options storage | ||
// merge preset | ||
const opt = Object.assign({}, rawOptions, preset); | ||
const opt = Object.assign({}, preset, rawOptions); | ||
@@ -61,2 +61,8 @@ // the max update rate in fps (redraw will only triggered on value change) | ||
// notty mode | ||
_options.noTTYOutput = mergeOption(opt.noTTYOutput, false); | ||
// schedule - 2s | ||
_options.notTTYSchedule = mergeOption(opt.notTTYSchedule, 2000); | ||
return _options; | ||
@@ -63,0 +69,0 @@ }, |
@@ -12,2 +12,10 @@ const _GenericBar = require('./generic-bar'); | ||
this.timer = null; | ||
// disable synchronous updates in notty mode | ||
if (this.options.noTTYOutput && this.terminal.isTTY() === false){ | ||
this.options.synchronousUpdate = false; | ||
} | ||
// update interval | ||
this.schedulingRate = (this.terminal.isTTY() ? this.options.throttleTime : this.options.notTTYSchedule); | ||
} | ||
@@ -26,4 +34,9 @@ | ||
// add new line in notty mode! | ||
if (this.options.noTTYOutput && this.terminal.isTTY() === false){ | ||
this.terminal.newline(); | ||
} | ||
// next update | ||
this.timer = setTimeout(this.render.bind(this), this.options.throttleTime); | ||
this.timer = setTimeout(this.render.bind(this), this.schedulingRate); | ||
} | ||
@@ -42,4 +55,4 @@ | ||
start(total, startValue, payload){ | ||
// progress is only visible in TTY mode! | ||
if (!this.terminal.isTTY()){ | ||
// progress updates are only visible in TTY mode! | ||
if (this.options.noTTYOutput === false && this.terminal.isTTY() === false){ | ||
return; | ||
@@ -46,0 +59,0 @@ } |
@@ -18,2 +18,6 @@ const _readline = require('readline'); | ||
cursorSave(){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
// save position | ||
@@ -25,2 +29,6 @@ this.stream.write('\x1B7'); | ||
cursorRestore(){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
// restore cursor | ||
@@ -32,2 +40,6 @@ this.stream.write('\x1B8'); | ||
cursor(enabled){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
if (enabled){ | ||
@@ -42,2 +54,6 @@ this.stream.write('\x1B[?25h'); | ||
cursorTo(x=null, y=null){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
// move cursor absolute | ||
@@ -49,2 +65,6 @@ _readline.cursorTo(this.stream, x, y); | ||
cursorRelative(dx=null, dy=null){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
// store current position | ||
@@ -59,2 +79,6 @@ this.dy = this.dy + dy; | ||
cursorRelativeReset(){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
// move cursor to initial line | ||
@@ -72,2 +96,6 @@ _readline.moveCursor(this.stream, 0, -this.dy); | ||
clearRight(){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
_readline.clearLine(this.stream, 1); | ||
@@ -78,2 +106,6 @@ } | ||
clearLine(){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
_readline.clearLine(this.stream, 0); | ||
@@ -84,2 +116,6 @@ } | ||
clearBottom(){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
_readline.clearScreenDown(this.stream); | ||
@@ -107,2 +143,6 @@ } | ||
lineWrapping(enabled){ | ||
if (!this.stream.isTTY){ | ||
return; | ||
} | ||
// store state | ||
@@ -124,3 +164,4 @@ this.linewrap = enabled; | ||
getWidth(){ | ||
return this.stream.columns || 80; | ||
// set max width to 80 in tty-mode and 200 in notty-mode | ||
return this.stream.columns || (this.stream.isTTY ? 80 : 200); | ||
} | ||
@@ -127,0 +168,0 @@ } |
The MIT License (X11 License) | ||
Copyright (c) 2015-2018 Andi Dittrich | ||
Copyright (c) 2015-2019 Andi Dittrich | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person |
{ | ||
"name": "cli-progress", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "easy to use progress-bar for command-line/terminal applications", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -9,5 +9,2 @@ CLI-Progress | ||
Install | ||
@@ -32,3 +29,3 @@ -------- | ||
* Custom Tokens to display additional data (payload) within the bar | ||
* Only visible in TTY environments | ||
* TTY and NOTTY mode | ||
* No callbacks required - designed as pure, external controlled UI widget | ||
@@ -151,3 +148,3 @@ * Works in Asynchronous and Synchronous tasks | ||
```js | ||
const _cliProgress = require('./cli-progress'); | ||
const _cliProgress = require('cli-progress'); | ||
@@ -225,4 +222,5 @@ // create new container | ||
- `synchronousUpdate` (type:boolean) - trigger redraw during `update()` in case threshold time x2 is exceeded (default: true) | ||
- `noTTYOutput` (type:boolean) - enable scheduled output to notty streams - e.g. redirect to files (default: false) | ||
- `notTTYSchedule` (type:int) - set the output schedule/interval for notty output in `ms` (default: 2000ms) | ||
Bar Formatting | ||
@@ -356,2 +354,2 @@ ----------------------------------- | ||
------- | ||
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)! | ||
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)! |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
40952
673
0
351