Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: tools/gardening/bin/bot.dart

Issue 2919693003: Fix gardening/bot help messages (Closed)
Patch Set: Add types and file header Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
1 import 'dart:io'; 6 import 'dart:io';
2 7
3 import 'compare_failures.dart' as compare_failures; 8 import 'compare_failures.dart' as compare_failures;
4 import 'current_summary.dart' as current_summary; 9 import 'current_summary.dart' as current_summary;
5 import 'status_summary.dart' as status_summary; 10 import 'status_summary.dart' as status_summary;
6 11
7 void help(List<String> args) { 12 typedef Future MainFunction(List<String> args);
13
14 help(List<String> args) async {
8 if (args.length == 1 && args[0] == "--help") { 15 if (args.length == 1 && args[0] == "--help") {
9 print("This help"); 16 print("This help");
10 return; 17 return null;
11 } 18 }
12 19
13 print("A script that combines multiple commands:\n"); 20 print("A script that combines multiple commands:\n");
14 21
15 commands.forEach((command, fun) { 22 for (String command in commands.keys) {
16 print("$command:"); 23 print(command);
17 fun(["--help"]); 24 print('-' * command.length);
25 await commands[command](["--help"]);
18 print(""); 26 print("");
19 }); 27 }
20 } 28 }
21 29
22 const commands = const { 30 const Map<String, MainFunction> commands = const <String, MainFunction>{
23 "help": help, 31 "help": help,
24 "compare-failures": compare_failures.main, 32 "compare-failures": compare_failures.main,
25 "current-summary": current_summary.main, 33 "current-summary": current_summary.main,
26 "status-summary": status_summary.main, 34 "status-summary": status_summary.main,
27 }; 35 };
28 36
29 void main(List<String> args) { 37 main(List<String> args) async {
30 if (args.isEmpty) { 38 if (args.isEmpty) {
31 help([]); 39 await help([]);
32 exit(-1); 40 exit(-1);
33 } 41 }
34 var command = commands[args[0]]; 42 var command = commands[args[0]];
35 if (command == null) { 43 if (command == null) {
36 help([]); 44 await help([]);
37 exit(-1); 45 exit(-1);
38 } 46 }
39 command(args.sublist(1)); 47 command(args.sublist(1));
40 } 48 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698