@@ -8,7 +8,7 @@ interact with the Dart SDK (such as the [analyzer][analyzer]).
8
8
9
9
[ ![ Build Status] ( https://travis-ci.org/dart-lang/cli_util.svg )] ( https://travis-ci.org/dart-lang/cli_util )
10
10
11
- ## Usage
11
+ ## Locating the Dart SDK
12
12
13
13
``` dart
14
14
import 'dart:io';
@@ -26,6 +26,38 @@ main(args) {
26
26
}
27
27
```
28
28
29
+ ## Displaying output and progress
30
+
31
+ ` package:cli_util ` can also be used to help CLI tools display output and progress.
32
+ It has a logging mechanism which can help differentiate between regular tool
33
+ output and error messages, and can facilitate having a more verbose (` -v ` ) mode for
34
+ output.
35
+
36
+ In addition, it can display an indeterminate progress spinner for longer running
37
+ tasks, and optionally display the elapsed time when finished:
38
+
39
+ ``` dart
40
+ import 'package:cli_util/cli_logging.dart';
41
+
42
+ main(List<String> args) async {
43
+ bool verbose = args.contains('-v');
44
+ Logger logger = verbose ? new Logger.verbose() : new Logger.standard();
45
+
46
+ logger.stdout('Hello world!');
47
+ logger.trace('message 1');
48
+ await new Future.delayed(new Duration(milliseconds: 200));
49
+ logger.trace('message 2');
50
+ logger.trace('message 3');
51
+
52
+ Progress progress = logger.progress('doing some work');
53
+ await new Future.delayed(new Duration(seconds: 2));
54
+ progress.finish(showTiming: true);
55
+
56
+ logger.stdout('All ${logger.ansi.emphasized('done')}.');
57
+ logger.flush();
58
+ }
59
+ ```
60
+
29
61
## Features and bugs
30
62
31
63
Please file feature requests and bugs at the [ issue tracker] [ tracker ] .
0 commit comments