| 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 library pub.progress; | 5 library pub.progress; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'log.dart' as log; | 10 import 'log.dart' as log; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 /// Stop animating the progress indicator. | 75 /// Stop animating the progress indicator. |
| 76 /// | 76 /// |
| 77 /// This will continue running the stopwatch so that the full time can be | 77 /// This will continue running the stopwatch so that the full time can be |
| 78 /// logged in [stop]. | 78 /// logged in [stop]. |
| 79 void stopAnimating() { | 79 void stopAnimating() { |
| 80 if (_timer == null) return; | 80 if (_timer == null) return; |
| 81 | 81 |
| 82 // Print a final message without a time indicator so that we don't leave a | 82 // Print a final message without a time indicator so that we don't leave a |
| 83 // misleading half-complete time indicator on the console. | 83 // misleading half-complete time indicator on the console. |
| 84 stdout.writeln("\r$_message..."); | 84 stdout.writeln(log.format("\r$_message...")); |
| 85 _timer.cancel(); | 85 _timer.cancel(); |
| 86 _timer = null; | 86 _timer = null; |
| 87 } | 87 } |
| 88 | 88 |
| 89 /// Refreshes the progress line. | 89 /// Refreshes the progress line. |
| 90 void _update() { | 90 void _update() { |
| 91 stdout.write("\r$_message... "); | 91 stdout.write(log.format("\r$_message... ")); |
| 92 | 92 |
| 93 // Show the time only once it gets noticeably long. | 93 // Show the time only once it gets noticeably long. |
| 94 if (_stopwatch.elapsed.inSeconds > 0) { | 94 if (_stopwatch.elapsed.inSeconds > 0) { |
| 95 stdout.write(log.gray(_time)); | 95 stdout.write(log.gray(_time)); |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 } | 98 } |
| OLD | NEW |