| // Copyright 2015 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| library mojom.command.check; |
| |
| import 'dart:async'; |
| import 'dart:io'; |
| |
| import 'package:args/args.dart'; |
| import 'package:args/command_runner.dart'; |
| import 'package:path/path.dart' as path; |
| |
| import 'mojom_command.dart'; |
| import '../generate.dart'; |
| import '../utils.dart'; |
| |
| class TreeCheckCommand extends MojomCommand { |
| String get name => 'tree-check'; |
| String get description => "Check bindings generated by the 'tree' command " |
| "against a canonical source"; |
| String get invocation => 'mojom tree-check'; |
| |
| Directory _canon; |
| Directory _root; |
| List<String> _skips; |
| |
| TreeCheckCommand() { |
| argParser.addOption('canon', |
| abbr: 'c', |
| help: 'Directory containing canonical .mojom.dart bindings.'); |
| argParser.addOption('root', |
| abbr: 'r', |
| defaultsTo: Directory.current.path, |
| help: 'Directory from which to begin the search for Dart packages.'); |
| argParser.addOption('skip', |
| abbr: 's', allowMultiple: true, help: 'Directories to skip.'); |
| } |
| |
| run() async { |
| await _validateArguments(); |
| var treeChecker = new TreeChecker(mojoSdk, _root, _canon, _skips, |
| verbose: verbose, profile: profile); |
| await treeChecker.check(); |
| return treeChecker.errors; |
| } |
| |
| _validateArguments() async { |
| await validateArguments(); |
| |
| if (argResults['canon'] == null) { |
| throw new CommandLineError("The 'tree-check' command requires a --canon" |
| " argument."); |
| } |
| |
| _canon = new Directory(makeAbsolute(argResults['canon'])); |
| _root = new Directory(makeAbsolute(argResults['root'])); |
| if (argResults['skip'] != null) { |
| _skips = argResults['skip'].map(makeAbsolute).toList(); |
| } |
| } |
| } |