Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Unified Diff: sdk/lib/_internal/pub_generated/lib/src/progress.dart

Issue 557563002: Store the async-await compiled pub code directly in the repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/pub_generated/lib/src/progress.dart
diff --git a/sdk/lib/_internal/pub_generated/lib/src/progress.dart b/sdk/lib/_internal/pub_generated/lib/src/progress.dart
new file mode 100644
index 0000000000000000000000000000000000000000..3d2454bdfc3f8d1baec17482ce0ff575d18e8cad
--- /dev/null
+++ b/sdk/lib/_internal/pub_generated/lib/src/progress.dart
@@ -0,0 +1,48 @@
+library pub.progress;
+import 'dart:async';
+import 'dart:io';
+import 'log.dart' as log;
+import 'utils.dart';
+class Progress {
+ Timer _timer;
+ final _stopwatch = new Stopwatch();
+ final String _message;
+ String get _time => "(${niceDuration(_stopwatch.elapsed)})";
+ Progress(this._message, {bool fine: false}) {
+ _stopwatch.start();
+ var level = fine ? log.Level.FINE : log.Level.MESSAGE;
+ if (stdioType(stdout) != StdioType.TERMINAL ||
+ !log.verbosity.isLevelVisible(level) ||
+ log.json.enabled ||
+ fine ||
+ log.verbosity.isLevelVisible(log.Level.FINE)) {
+ log.write(level, "$_message...");
+ return;
+ }
+ _update();
+ _timer = new Timer.periodic(new Duration(milliseconds: 100), (_) {
+ _update();
+ });
+ }
+ void stop() {
+ _stopwatch.stop();
+ log.fine("$_message finished $_time.");
+ if (_timer == null) return;
+ _timer.cancel();
+ _timer = null;
+ _update();
+ stdout.writeln();
+ }
+ void stopAnimating() {
+ if (_timer == null) return;
+ stdout.writeln(log.format("\r$_message..."));
+ _timer.cancel();
+ _timer = null;
+ }
+ void _update() {
+ stdout.write(log.format("\r$_message... "));
+ if (_stopwatch.elapsed.inSeconds > 0) {
+ stdout.write(log.gray(_time));
+ }
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698