OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'compare_failures.dart' as compare_failures; | 8 import 'compare_failures.dart' as compare_failures; |
9 import 'current_summary.dart' as current_summary; | 9 import 'current_summary.dart' as current_summary; |
| 10 import 'find_shard.dart' as find_shard; |
10 import 'status_summary.dart' as status_summary; | 11 import 'status_summary.dart' as status_summary; |
11 import 'find_shard.dart' as find_shard; | 12 import 'summary.dart' as summary; |
12 | 13 |
13 typedef Future MainFunction(List<String> args); | 14 typedef Future MainFunction(List<String> args); |
14 | 15 |
15 help(List<String> args) async { | 16 help(List<String> args) async { |
16 if (args.length == 1 && args[0] == "--help") { | 17 if (args.length == 1 && args[0] == "--help") { |
17 print("This help"); | 18 print("This help"); |
18 return null; | 19 return null; |
19 } | 20 } |
20 | 21 |
21 print("A script that combines multiple commands:\n"); | 22 print("A script that combines multiple commands:\n"); |
22 | 23 |
23 for (String command in commands.keys) { | 24 for (String command in commands.keys) { |
24 print(command); | 25 print(command); |
25 print('-' * command.length); | 26 print('-' * command.length); |
26 await commands[command](["--help"]); | 27 await commands[command](["--help"]); |
27 print(""); | 28 print(""); |
28 } | 29 } |
29 } | 30 } |
30 | 31 |
31 const Map<String, MainFunction> commands = const <String, MainFunction>{ | 32 const Map<String, MainFunction> commands = const <String, MainFunction>{ |
32 "help": help, | 33 "help": help, |
| 34 "summary": summary.main, |
33 "compare-failures": compare_failures.main, | 35 "compare-failures": compare_failures.main, |
34 "current-summary": current_summary.main, | 36 "current-summary": current_summary.main, |
35 "status-summary": status_summary.main, | 37 "status-summary": status_summary.main, |
36 "find-shard": find_shard.main, | 38 "find-shard": find_shard.main, |
37 }; | 39 }; |
38 | 40 |
39 main(List<String> args) async { | 41 main(List<String> args) async { |
40 if (args.isEmpty) { | 42 if (args.isEmpty) { |
41 await help([]); | 43 await help([]); |
42 exit(-1); | 44 exit(-1); |
43 } | 45 } |
44 var command = commands[args[0]]; | 46 var command = commands[args[0]]; |
45 if (command == null) { | 47 if (command == null) { |
46 await help([]); | 48 await help([]); |
47 exit(-1); | 49 exit(-1); |
48 } | 50 } |
49 command(args.sublist(1)); | 51 command(args.sublist(1)); |
50 } | 52 } |
OLD | NEW |