OLD | NEW |
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 /// Runs dev_compiler's checker, and optionally the code generator. | 6 /// Runs dev_compiler's checker, and optionally the code generator. |
7 /// Also can run a server for local development. | 7 /// Also can run a server for local development. |
8 library dev_compiler.bin.devc; | 8 library dev_compiler.bin.devc; |
9 | 9 |
10 import 'dart:io'; | 10 import 'dart:io'; |
11 | 11 |
12 import 'package:dev_compiler/src/compiler.dart' show validateOptions, compile; | 12 import 'package:dev_compiler/src/compiler.dart' |
| 13 show validateOptions, compile, setupLogger; |
13 import 'package:dev_compiler/src/options.dart'; | 14 import 'package:dev_compiler/src/options.dart'; |
| 15 import 'package:dev_compiler/src/server/server.dart' show DevServer; |
14 | 16 |
15 void _showUsageAndExit() { | 17 void _showUsageAndExit() { |
16 print('usage: dartdevc [<options>] <file.dart>...\n'); | 18 print('usage: dartdevc [<options>] <file.dart>...\n'); |
17 print('<file.dart> is one or more Dart files to process.\n'); | 19 print('<file.dart> is one or more Dart files to process.\n'); |
18 print('<options> include:\n'); | 20 print('<options> include:\n'); |
19 print(argParser.usage); | 21 print(argParser.usage); |
20 exit(1); | 22 exit(1); |
21 } | 23 } |
22 | 24 |
23 main(List<String> args) async { | 25 main(List<String> args) async { |
24 var options = validateOptions(args); | 26 var options = validateOptions(args); |
25 if (options == null || options.help) _showUsageAndExit(); | 27 if (options == null || options.help) _showUsageAndExit(); |
26 | 28 |
27 bool success = await compile(options); | 29 setupLogger(options.logLevel, print); |
28 exit(success ? 0 : 1); | 30 |
| 31 if (options.serverMode) { |
| 32 new DevServer(options).start(); |
| 33 } else { |
| 34 var success = compile(options); |
| 35 exit(success ? 0 : 1); |
| 36 } |
29 } | 37 } |
OLD | NEW |