OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 library mojom.command.check; | |
6 | |
7 import 'dart:async'; | |
8 import 'dart:io'; | |
9 | |
10 import 'package:args/args.dart'; | |
11 import 'package:args/command_runner.dart'; | |
12 import 'package:mojom/src/commands/mojom_command.dart'; | |
13 import 'package:mojom/src/generate.dart'; | |
14 import 'package:mojom/src/utils.dart'; | |
15 import 'package:path/path.dart' as path; | |
16 | |
17 class CheckCommand extends MojomCommand { | |
18 String get name => 'check'; | |
19 String get description => "Check bindings generated by the 'gen' command " | |
20 "against a canonical source"; | |
21 String get invocation => | |
22 'mojom.dart check -c path/to/canon -r mojoms/ -o dart-packages/'; | |
23 | |
24 Directory _canon; | |
25 Directory _dartRoot; | |
26 | |
27 CheckCommand() { | |
28 argParser.addOption('canon', | |
29 abbr: 'c', | |
30 help: 'Directory containing canonical .mojom.dart bindings.'); | |
31 argParser.addOption('output', | |
32 abbr: 'o', | |
33 defaultsTo: Directory.current.path, | |
34 help: 'Directory containing Dart packages.'); | |
35 } | |
36 | |
37 run() async { | |
38 MojomCommand.setupLogging(); | |
39 await _validateArguments(); | |
40 var treeChecker = | |
41 new TreeChecker(mojoSdk, mojomRoot, _dartRoot, _canon, skips); | |
42 await treeChecker.check(); | |
43 return treeChecker.errors; | |
44 } | |
45 | |
46 _validateArguments() async { | |
47 await validateArguments(); | |
48 | |
49 if (argResults['canon'] == null) { | |
50 throw new CommandLineError("The 'tree-check' command requires a --canon" | |
51 " argument."); | |
52 } | |
53 _canon = new Directory(makeAbsolute(argResults['canon'])); | |
54 if (!await _canon.exists()) { | |
55 throw new CommandLineError("The specified canonical output directory: " | |
56 "$_canon does not exist."); | |
57 } | |
58 _dartRoot = new Directory(makeAbsolute(argResults['output'])); | |
59 if (!await _dartRoot.exists()) { | |
60 throw new CommandLineError( | |
61 'Specified --output directory $_dartRoot does not exist'); | |
62 } | |
63 } | |
64 } | |
OLD | NEW |