| Index: tools/gardening/lib/src/util.dart
|
| diff --git a/tools/gardening/lib/src/util.dart b/tools/gardening/lib/src/util.dart
|
| index 278d4e3c29db43e3ba67ceb562614b2e77a1c319..66f986944367fe9fb7bfb4fbf7565bca703e2c0c 100644
|
| --- a/tools/gardening/lib/src/util.dart
|
| +++ b/tools/gardening/lib/src/util.dart
|
| @@ -6,6 +6,10 @@ import 'dart:async';
|
| import 'dart:convert';
|
| import 'dart:io';
|
|
|
| +import 'package:args/args.dart';
|
| +
|
| +import 'cache.dart';
|
| +
|
| /// Split [text] using [infixes] as infix markers.
|
| List<String> split(String text, List<String> infixes) {
|
| List<String> result = <String>[];
|
| @@ -27,9 +31,15 @@ String padRight(String text, int length) {
|
| return text;
|
| }
|
|
|
| -const bool LOG = const bool.fromEnvironment('LOG', defaultValue: false);
|
| +/// Pad [text] with spaces to the left to fit [length].
|
| +String padLeft(String text, int length) {
|
| + if (text.length < length) return '${' ' * (length - text.length)}${text}';
|
| + return text;
|
| +}
|
| +
|
| +bool LOG = const bool.fromEnvironment('LOG', defaultValue: false);
|
|
|
| -void log(String text) {
|
| +void log(Object text) {
|
| if (LOG) print(text);
|
| }
|
|
|
| @@ -39,3 +49,22 @@ Future<String> readUriAsText(HttpClient client, Uri uri) async {
|
| HttpClientResponse response = await request.close();
|
| return await response.transform(UTF8.decoder).join();
|
| }
|
| +
|
| +ArgParser createArgParser() {
|
| + ArgParser argParser = new ArgParser();
|
| + argParser.addFlag('verbose',
|
| + abbr: 'v', negatable: false, help: "Turn on logging output.");
|
| + argParser.addOption('cache',
|
| + help: "Use <dir> for caching test output.\n"
|
| + "Defaults to 'temp/gardening-cache/'.");
|
| + return argParser;
|
| +}
|
| +
|
| +void processArgResults(ArgResults argResults) {
|
| + if (argResults['verbose']) {
|
| + LOG = true;
|
| + }
|
| + if (argResults['cache'] != null) {
|
| + cache.base = Uri.base.resolve('${argResults['cache']}/');
|
| + }
|
| +}
|
|
|