OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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:grinder/grinder.dart'; | 7 import 'package:grinder/grinder.dart'; |
8 import 'package:unscripted/unscripted.dart'; | 8 import 'package:unscripted/unscripted.dart'; |
9 | 9 |
| 10 import 'doc.dart'; |
10 import 'rule.dart'; | 11 import 'rule.dart'; |
11 | 12 |
12 main([List<String> args]) { | 13 main([List<String> args]) { |
13 addTask(new GrinderTask('rule', taskFunction: () { | 14 _addTask('rule', |
14 String ruleName = context.invocation.positionals.first; | 15 parser: (String name) => |
15 _generate(ruleName); | 16 generateRule(name, outDir: Directory.current.path), |
16 }, | |
17 description: 'Generate a lint rule stub.', | 17 description: 'Generate a lint rule stub.', |
18 positionals: [new Positional(valueHelp: 'Name of rule to generate')])); | 18 valueHelp: 'Name of rule to generate.'); |
| 19 |
| 20 _addTask('docs', |
| 21 parser: (String outDir) => generateDocs(outDir), |
| 22 description: 'Generate lint rule docs.', |
| 23 valueHelp: 'Documentation `lints/` directory.'); |
19 | 24 |
20 grind(args); | 25 grind(args); |
21 } | 26 } |
22 | 27 |
23 void _generate(String ruleName) { | 28 _addTask(String name, {String description, Parser parser, String valueHelp}) { |
24 generateRule(ruleName, outDir: Directory.current.path); | 29 addTask(new GrinderTask(name, taskFunction: () { |
| 30 String value = context.invocation.positionals.first; |
| 31 parser(value); |
| 32 }, |
| 33 description: description, |
| 34 positionals: [new Positional(valueHelp: valueHelp)])); |
25 } | 35 } |
| 36 |
| 37 typedef String Parser(String); |
OLD | NEW |