| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:convert' show |
| 6 JSON; |
| 7 |
| 8 import 'dart:io'; |
| 9 |
| 10 import 'package:testing/src/run_tests.dart' show |
| 11 CommandLine; |
| 12 |
| 13 main(List<String> arguments) async { |
| 14 CommandLine cl = CommandLine.parse(arguments); |
| 15 Set<String> fields = cl.commaSeparated("--fields="); |
| 16 if (fields.isEmpty) { |
| 17 fields.addAll(["uri", "offset", "json:error"]); |
| 18 } |
| 19 for (String filename in cl.arguments) { |
| 20 String json = await new File(filename).readAsString(); |
| 21 Map<String, dynamic> data = JSON.decode(json) as Map<String, dynamic>; |
| 22 StringBuffer sb = new StringBuffer(); |
| 23 bool isFirst = true; |
| 24 for (String field in fields) { |
| 25 if (!isFirst) { |
| 26 sb.write(":"); |
| 27 } |
| 28 if (field.startsWith("json:")) { |
| 29 field = field.substring(5); |
| 30 sb.write(JSON.encode(data[field])); |
| 31 } else { |
| 32 sb.write(data[field]); |
| 33 } |
| 34 isFirst = false; |
| 35 } |
| 36 print("$sb"); |
| 37 } |
| 38 } |
| OLD | NEW |