Better progress (#6677)

* make showElapsedTime default to true

* support nested progresses

* improve hot reload message

* rethrow
This commit is contained in:
Devon Carew
2016-11-03 13:28:17 -07:00
committed by GitHub
parent 1f1adcaa0e
commit fcfb2a5c55
15 changed files with 74 additions and 56 deletions

View File

@@ -37,7 +37,7 @@ abstract class Logger {
}
class Status {
void stop({ bool showElapsedTime: false }) { }
void stop({ bool showElapsedTime: true }) { }
void cancel() { }
}
@@ -73,15 +73,17 @@ class StdoutLogger extends Logger {
@override
Status startProgress(String message) {
_status?.cancel();
_status = null;
if (supportsColor) {
_status = new _AnsiStatus(message);
return _status;
} else {
printStatus(message);
if (_status != null) {
// Ignore nested progresses; return a no-op status object.
return new Status();
} else {
if (supportsColor) {
_status = new _AnsiStatus(message);
return _status;
} else {
printStatus(message);
return new Status();
}
}
}
}
@@ -244,13 +246,13 @@ class _AnsiStatus extends Status {
}
@override
void stop({ bool showElapsedTime: false }) {
void stop({ bool showElapsedTime: true }) {
if (!live)
return;
live = false;
if (showElapsedTime) {
print('\b\b\b\b${stopwatch.elapsedMilliseconds.toString()}ms');
print('\b\b\b\b\b${stopwatch.elapsedMilliseconds.toString().padLeft(3)}ms');
} else {
print('\b ');
}