OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Message logging. | 5 /// Message logging. |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'package:args/command_runner.dart'; | 10 import 'package:args/command_runner.dart'; |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 stderr.writeln('---- End log transcript ----'); | 392 stderr.writeln('---- End log transcript ----'); |
393 } | 393 } |
394 | 394 |
395 /// Prints [message] then displays an updated elapsed time until the future | 395 /// Prints [message] then displays an updated elapsed time until the future |
396 /// returned by [callback] completes. | 396 /// returned by [callback] completes. |
397 /// | 397 /// |
398 /// If anything else is logged during this (including another call to | 398 /// If anything else is logged during this (including another call to |
399 /// [progress]) that cancels the progress animation, although the total time | 399 /// [progress]) that cancels the progress animation, although the total time |
400 /// will still be printed once it finishes. If [fine] is passed, the progress | 400 /// will still be printed once it finishes. If [fine] is passed, the progress |
401 /// information will only be visible at [Level.FINE]. | 401 /// information will only be visible at [Level.FINE]. |
402 Future progress(String message, Future callback(), {bool fine: false}) { | 402 Future/*<T>*/ progress/*<T>*/(String message, Future/*<T>*/ callback(), |
| 403 {bool fine: false}) { |
403 _stopProgress(); | 404 _stopProgress(); |
404 | 405 |
405 var progress = new Progress(message, fine: fine); | 406 var progress = new Progress(message, fine: fine); |
406 _animatedProgress = progress; | 407 _animatedProgress = progress; |
407 return callback().whenComplete(progress.stop); | 408 return callback().whenComplete(progress.stop); |
408 } | 409 } |
409 | 410 |
410 /// Stops animating the running progress indicator, if currently running. | 411 /// Stops animating the running progress indicator, if currently running. |
411 void _stopProgress() { | 412 void _stopProgress() { |
412 if (_animatedProgress != null) _animatedProgress.stopAnimating(); | 413 if (_animatedProgress != null) _animatedProgress.stopAnimating(); |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 message(_firstMessage); | 653 message(_firstMessage); |
653 } else { | 654 } else { |
654 message(_template.replaceAll("##", _count.toString())); | 655 message(_template.replaceAll("##", _count.toString())); |
655 } | 656 } |
656 } | 657 } |
657 | 658 |
658 void _initTimer() { | 659 void _initTimer() { |
659 _timer = new Timer(_window, end); | 660 _timer = new Timer(_window, end); |
660 } | 661 } |
661 } | 662 } |
OLD | NEW |