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 'status_summary.dart' as status_summary; | 10 import 'status_summary.dart' as status_summary; |
| 11 import 'find_shard.dart' as find_shard; |
11 | 12 |
12 typedef Future MainFunction(List<String> args); | 13 typedef Future MainFunction(List<String> args); |
13 | 14 |
14 help(List<String> args) async { | 15 help(List<String> args) async { |
15 if (args.length == 1 && args[0] == "--help") { | 16 if (args.length == 1 && args[0] == "--help") { |
16 print("This help"); | 17 print("This help"); |
17 return null; | 18 return null; |
18 } | 19 } |
19 | 20 |
20 print("A script that combines multiple commands:\n"); | 21 print("A script that combines multiple commands:\n"); |
21 | 22 |
22 for (String command in commands.keys) { | 23 for (String command in commands.keys) { |
23 print(command); | 24 print(command); |
24 print('-' * command.length); | 25 print('-' * command.length); |
25 await commands[command](["--help"]); | 26 await commands[command](["--help"]); |
26 print(""); | 27 print(""); |
27 } | 28 } |
28 } | 29 } |
29 | 30 |
30 const Map<String, MainFunction> commands = const <String, MainFunction>{ | 31 const Map<String, MainFunction> commands = const <String, MainFunction>{ |
31 "help": help, | 32 "help": help, |
32 "compare-failures": compare_failures.main, | 33 "compare-failures": compare_failures.main, |
33 "current-summary": current_summary.main, | 34 "current-summary": current_summary.main, |
34 "status-summary": status_summary.main, | 35 "status-summary": status_summary.main, |
| 36 "find-shard": find_shard.main, |
35 }; | 37 }; |
36 | 38 |
37 main(List<String> args) async { | 39 main(List<String> args) async { |
38 if (args.isEmpty) { | 40 if (args.isEmpty) { |
39 await help([]); | 41 await help([]); |
40 exit(-1); | 42 exit(-1); |
41 } | 43 } |
42 var command = commands[args[0]]; | 44 var command = commands[args[0]]; |
43 if (command == null) { | 45 if (command == null) { |
44 await help([]); | 46 await help([]); |
45 exit(-1); | 47 exit(-1); |
46 } | 48 } |
47 command(args.sublist(1)); | 49 command(args.sublist(1)); |
48 } | 50 } |
OLD | NEW |