| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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:io'; | 5 import 'dart:io'; |
| 6 | 6 |
| 7 import 'package:args/args.dart'; | 7 import 'package:args/args.dart'; |
| 8 | 8 |
| 9 String capitalize(String s) => s.substring(0, 1).toUpperCase() + s.substring(1); | 9 String capitalize(String s) => s.substring(0, 1).toUpperCase() + s.substring(1); |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 var libName = options['library']; | 60 var libName = options['library']; |
| 61 | 61 |
| 62 if (libName == null) { | 62 if (libName == null) { |
| 63 printUsage(parser); | 63 printUsage(parser); |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Generate rule stub | 67 // Generate rule stub. |
| 68 generateStub(libName, outDir: outDir); | 68 generateStub(libName, outDir: outDir); |
| 69 | 69 |
| 70 // Generate test stub | 70 // Generate test stub. |
| 71 generateTest(libName, outDir: outDir); | 71 generateTest(libName, outDir: outDir); |
| 72 |
| 73 // Update rule registry. |
| 74 updateRuleRegistry(libName); |
| 72 } | 75 } |
| 73 | 76 |
| 74 void printUsage(ArgParser parser, [String error]) { | 77 void printUsage(ArgParser parser, [String error]) { |
| 75 var message = error ?? 'Generates rule stubs.'; | 78 var message = error ?? 'Generates rule stubs.'; |
| 76 | 79 |
| 77 stdout.write('''$message | 80 stdout.write('''$message |
| 78 Usage: rule | 81 Usage: rule |
| 79 ${parser.usage} | 82 ${parser.usage} |
| 80 '''); | 83 '''); |
| 81 } | 84 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 132 |
| 130 | 133 |
| 131 } | 134 } |
| 132 """; | 135 """; |
| 133 | 136 |
| 134 String _generateTest(String libName, String className) => ''' | 137 String _generateTest(String libName, String className) => ''' |
| 135 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 138 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 136 // for details. All rights reserved. Use of this source code is governed by a | 139 // for details. All rights reserved. Use of this source code is governed by a |
| 137 // BSD-style license that can be found in the LICENSE file. | 140 // BSD-style license that can be found in the LICENSE file. |
| 138 | 141 |
| 142 // test w/ `dart test/util/solo_test.dart $libName` |
| 143 |
| 139 '''; | 144 '''; |
| 140 | 145 |
| 141 void addToRuleIndex(String libName, String className) { | 146 void updateRuleRegistry(String libName) { |
| 142 //TODO: find right place to insert into imports and ruleMap | 147 //TODO: find right place to insert into imports and ruleMap |
| 148 print("Don't forget to update lib/rules.dart with a line like:"); |
| 149 print(" ..register(new ${toClassName(libName)}())"); |
| 150 print("Then run your test like so:"); |
| 151 print(" dart test/util/solo_test.dart $libName"); |
| 143 } | 152 } |
| OLD | NEW |