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

Side by Side Diff: packages/cli_util/README.md

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 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 unified diff | Download patch
« no previous file with comments | « packages/cli_util/CONTRIBUTING.md ('k') | packages/cli_util/analysis_options.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # cli_util 1 # cli_util
2 2
3 A library to help in building Dart command-line apps. 3 A library to help in building Dart command-line apps.
4 4
5 In particular, `cli_util` provides a simple, standardized way to get the current 5 In particular, `cli_util` provides a simple, standardized way to get the current
6 SDK directory. Useful, especially, when building client applications that 6 SDK directory. Useful, especially, when building client applications that
7 interact with the Dart SDK (such as the [analyzer][analyzer]). 7 interact with the Dart SDK (such as the [analyzer][analyzer]).
8 8
9 [![Build Status](https://travis-ci.org/dart-lang/cli_util.svg)](https://travis-c i.org/dart-lang/cli_util) 9 [![Build Status](https://travis-ci.org/dart-lang/cli_util.svg)](https://travis-c i.org/dart-lang/cli_util)
10 [![Pub](https://img.shields.io/pub/v/cli_util.svg)](https://pub.dartlang.org/pac kages/cli_util)
10 11
11 ## Usage 12 ## Locating the Dart SDK
12 13
13 ```dart 14 ```dart
14 import 'dart:io'; 15 import 'dart:io';
15 16
16 import 'package:cli_util/cli_util.dart'; 17 import 'package:cli_util/cli_util.dart';
17 import 'package:path/path.dart' as path; 18 import 'package:path/path.dart' as path;
18 19
19 main(args) { 20 main(args) {
20 // Get sdk dir from cli_util 21 // Get sdk dir from cli_util.
21 Directory sdkDir = getSdkDir(args); 22 String sdkPath = getSdkPath();
22 23
23 // Do stuff... For example, print version string 24 // Do stuff... For example, print version string
24 File versionFile = new File(path.join(sdkDir.path, 'version')); 25 File versionFile = new File(path.join(sdkPath, 'version'));
25 print(versionFile.readAsStringSync()); 26 print(versionFile.readAsStringSync());
26 } 27 }
27 ``` 28 ```
28 29
30 ## Displaying output and progress
31
32 `package:cli_util` can also be used to help CLI tools display output and progres s.
33 It has a logging mechanism which can help differentiate between regular tool
34 output and error messages, and can facilitate having a more verbose (`-v`) mode for
35 output.
36
37 In addition, it can display an indeterminate progress spinner for longer running
38 tasks, and optionally display the elapsed time when finished:
39
40 ```dart
41 import 'package:cli_util/cli_logging.dart';
42
43 main(List<String> args) async {
44 bool verbose = args.contains('-v');
45 Logger logger = verbose ? new Logger.verbose() : new Logger.standard();
46
47 logger.stdout('Hello world!');
48 logger.trace('message 1');
49 await new Future.delayed(new Duration(milliseconds: 200));
50 logger.trace('message 2');
51 logger.trace('message 3');
52
53 Progress progress = logger.progress('doing some work');
54 await new Future.delayed(new Duration(seconds: 2));
55 progress.finish(showTiming: true);
56
57 logger.stdout('All ${logger.ansi.emphasized('done')}.');
58 logger.flush();
59 }
60 ```
61
29 ## Features and bugs 62 ## Features and bugs
30 63
31 Please file feature requests and bugs at the [issue tracker][tracker]. 64 Please file feature requests and bugs at the [issue tracker][tracker].
32 65
33 [analyzer]: https://pub.dartlang.org/packages/analyzer 66 [analyzer]: https://pub.dartlang.org/packages/analyzer
34 [tracker]: https://github.com/dart-lang/cli_util/issues 67 [tracker]: https://github.com/dart-lang/cli_util/issues
OLDNEW
« no previous file with comments | « packages/cli_util/CONTRIBUTING.md ('k') | packages/cli_util/analysis_options.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698