Skip to content
This repository was archived by the owner on Nov 1, 2024. It is now read-only.

Commit a47b1ed

Browse files
committed
update the readme
1 parent f102e86 commit a47b1ed

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interact with the Dart SDK (such as the [analyzer][analyzer]).
88

99
[![Build Status](https://travis-ci.org/dart-lang/cli_util.svg)](https://travis-ci.org/dart-lang/cli_util)
1010

11-
## Usage
11+
## Locating the Dart SDK
1212

1313
```dart
1414
import 'dart:io';
@@ -26,6 +26,38 @@ main(args) {
2626
}
2727
```
2828

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+
2961
## Features and bugs
3062

3163
Please file feature requests and bugs at the [issue tracker][tracker].

0 commit comments

Comments
 (0)