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.tree; | |
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 GenCommand extends MojomCommand { | |
18 String get name => 'gen'; | |
19 String get description => | |
20 'Generate bindings for .mojom files under --mojom-root into Dart ' | |
21 'packages under --output'; | |
22 String get invocation => 'mojom.dart gen -r mojoms/ -o dart-packages/'; | |
23 | |
24 Directory _dartRoot; | |
25 | |
26 GenCommand() { | |
27 argParser.addOption('output', | |
28 abbr: 'o', | |
29 defaultsTo: Directory.current.path, | |
30 help: 'Directory where Dart packages live into which we generate the ' | |
31 'resulting bindings.'); | |
32 } | |
33 | |
34 run() async { | |
35 MojomCommand.setupLogging(); | |
36 await _validateArguments(); | |
37 var treeGenerator = | |
38 new TreeGenerator(mojoSdk, mojomRoot, _dartRoot, skips, dryRun: dryRun); | |
39 await treeGenerator.generate(); | |
40 return treeGenerator.errors; | |
41 } | |
42 | |
43 _validateArguments() async { | |
44 await validateArguments(); | |
45 _dartRoot = new Directory(makeAbsolute(argResults['output'])); | |
46 if (!await _dartRoot.exists()) { | |
47 throw new CommandLineError( | |
48 'Specified --output directory $_dartRoot does not exist'); | |
49 } | |
50 } | |
51 } | |
OLD | NEW |