Name: cli_util
Owner: Dart
Description: A library to help in building Dart command-line apps
Created: 2015-02-03 18:02:08.0
Updated: 2018-05-16 21:25:53.0
Pushed: 2018-05-16 21:26:41.0
Homepage: https://pub.dartlang.org/packages/cli_util
Size: 34
Language: Dart
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
A library to help in building Dart command-line apps.
In particular, cli_util
provides a simple, standardized way to get the current
SDK directory. Useful, especially, when building client applications that
interact with the Dart SDK (such as the analyzer).
rt 'dart:io';
rt 'package:cli_util/cli_util.dart';
rt 'package:path/path.dart' as path;
(args) {
Get sdk dir from cli_util.
ring sdkPath = getSdkPath();
Do stuff... For example, print version string
le versionFile = new File(path.join(sdkPath, 'version'));
int(versionFile.readAsStringSync());
package:cli_util
can also be used to help CLI tools display output and progress.
It has a logging mechanism which can help differentiate between regular tool
output and error messages, and can facilitate having a more verbose (-v
) mode for
output.
In addition, it can display an indeterminate progress spinner for longer running tasks, and optionally display the elapsed time when finished:
rt 'package:cli_util/cli_logging.dart';
(List<String> args) async {
ol verbose = args.contains('-v');
gger logger = verbose ? new Logger.verbose() : new Logger.standard();
gger.stdout('Hello world!');
gger.trace('message 1');
ait new Future.delayed(new Duration(milliseconds: 200));
gger.trace('message 2');
gger.trace('message 3');
ogress progress = logger.progress('doing some work');
ait new Future.delayed(new Duration(seconds: 2));
ogress.finish(showTiming: true);
gger.stdout('All ${logger.ansi.emphasized('done')}.');
gger.flush();
Please file feature requests and bugs at the issue tracker.