Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: mojo/public/dart/mojom/lib/src/commands/mojom_command.dart

Issue 1441033002: Move mojo and mojom from mojo/public/dart to mojo/dart/packages (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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;
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:logging/logging.dart' as logging;
13 import 'package:mojom/src/utils.dart';
14 import 'package:path/path.dart' as path;
15
16 abstract class MojomCommand extends Command {
17 bool _verbose;
18 bool _dryRun;
19 bool _errorOnDuplicate;
20 Directory _mojomRoot;
21 Directory _mojoSdk;
22 List<String> _skips;
23
24 bool get verbose => _verbose;
25 bool get dryRun => _dryRun;
26 bool get errorOnDuplicate => _errorOnDuplicate;
27 Directory get mojomRoot => _mojomRoot;
28 Directory get mojoSdk => _mojoSdk;
29 List<String> get skips => _skips;
30
31 static setupLogging() {
32 if (log == null) {
33 logging.hierarchicalLoggingEnabled = true;
34 log = new logging.Logger('mojom');
35 log.onRecord.listen((logging.LogRecord rec) {
36 print('${rec.level.name}: ${rec.message}');
37 });
38 }
39 }
40
41 validateArguments() async {
42 assert(log != null);
43 if (globalResults['verbose']) {
44 log.level = logging.Level.INFO;
45 } else {
46 log.level = logging.Level.WARNING;
47 }
48 _dryRun = globalResults['dry-run'];
49 _errorOnDuplicate = !globalResults['ignore-duplicates'];
50
51 final mojoSdkPath = globalResults['mojo-sdk'];
52 if (mojoSdkPath == null) {
53 throw new CommandLineError(
54 "The Mojo SDK directory must be specified with the --mojo-sdk "
55 "flag or the MOJO_SDK environment variable.");
56 }
57 _mojomRoot = new Directory(makeAbsolute(globalResults['mojom-root']));
58 _mojoSdk = new Directory(makeAbsolute(mojoSdkPath));
59 log.info("Mojo SDK = $_mojoSdk");
60 if (!(await _mojoSdk.exists())) {
61 throw new CommandLineError(
62 "The specified Mojo SDK directory $_mojoSdk must exist.");
63 }
64 if (globalResults['skip'] != null) {
65 _skips = globalResults['skip'].map(makeAbsolute).toList();
66 }
67 }
68
69 String toString() {
70 String dart = makeRelative(Platform.executable);
71 String script = makeRelative(path.fromUri(Platform.script));
72 String globals = globalResults.arguments.join(" ");
73 return "$dart $script $globals";
74 }
75 }
OLDNEW
« no previous file with comments | « mojo/public/dart/mojom/lib/src/commands/gen.dart ('k') | mojo/public/dart/mojom/lib/src/commands/single.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698