OLD | NEW |
---|---|
1 #!/usr/bin/env dart | 1 #!/usr/bin/env dart |
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2012, 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 /** | 6 /** |
7 * Script to compile each dart web component examples and copy the | 7 * Script to compile each dart web component examples and copy the |
8 * generated code to an output directory. | 8 * generated code to an output directory. |
9 */ | 9 */ |
10 library build_examples; | 10 library build_examples; |
11 | 11 |
12 import 'dart:io'; | 12 import 'dart:io'; |
13 import 'package:args/args.dart'; | 13 import 'package:args/args.dart'; |
14 import 'package:web_ui/dwc.dart' as dwc; | 14 import 'package:web_ui/dwc.dart' as dwc; |
15 | 15 |
16 main() { | 16 main() { |
17 var argParser = new ArgParser(); | 17 var argParser = new ArgParser(); |
18 argParser.addFlag('help', abbr: 'h', | |
19 help: 'Displayes this help message', defaultsTo:false, negatable: false); | |
Jennifer Messerly
2012/12/12 02:02:03
nit, missing space in "defaultsTo:false" (and corr
Siggi Cherem (dart-lang)
2012/12/13 18:05:23
Done.
| |
18 argParser.addOption('out', abbr: 'o', | 20 argParser.addOption('out', abbr: 'o', |
19 help: 'output directory for the generated code', | 21 help: 'output directory for the generated code', |
20 defaultsTo: 'generated'); | 22 defaultsTo: 'generated'); |
21 var args = argParser.parse(new Options().arguments); | 23 var args = argParser.parse(new Options().arguments); |
22 | 24 |
25 if (args['help']) { | |
26 print('Usage: build_examples.dart [-o outdir] [file1, file2, ...]'); | |
27 print(argParser.getUsage()); | |
28 exit(0); | |
29 } | |
30 | |
23 var output = args['out']; | 31 var output = args['out']; |
24 if (args.rest.isEmpty) { | 32 if (args.rest.isEmpty) { |
25 var dir = new Directory.current(); | 33 var dir = new Directory.current(); |
26 listFiles(dir, | 34 listFiles(dir, |
27 (filename) => filename.endsWith('.html') && !filename.startsWith('_')) | 35 (filename) => filename.endsWith('.html') && !filename.startsWith('_')) |
28 .then((inputs) { | 36 .then((inputs) { |
29 buildAll(inputs.map((file) => new Path(file).filename), output); | 37 buildAll(inputs.map((file) => new Path(file).filename), output); |
30 }); | 38 }); |
31 } else { | 39 } else { |
32 buildAll(args.rest, output); | 40 buildAll(args.rest, output); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 final String NO_COLOR = '\u001b[0m'; | 89 final String NO_COLOR = '\u001b[0m'; |
82 | 90 |
83 Stopwatch startTime() => new Stopwatch()..start(); | 91 Stopwatch startTime() => new Stopwatch()..start(); |
84 | 92 |
85 void stopTime(Stopwatch watch, String message) { | 93 void stopTime(Stopwatch watch, String message) { |
86 watch.stop(); | 94 watch.stop(); |
87 var duration = watch.elapsedMilliseconds; | 95 var duration = watch.elapsedMilliseconds; |
88 print('$message: $GREEN_COLOR$duration ms$NO_COLOR'); | 96 print('$message: $GREEN_COLOR$duration ms$NO_COLOR'); |
89 totalTime.add('$message: $GREEN_COLOR$duration ms$NO_COLOR'); | 97 totalTime.add('$message: $GREEN_COLOR$duration ms$NO_COLOR'); |
90 } | 98 } |
OLD | NEW |