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

Side by Side Diff: lib/src/options.dart

Issue 11450020: (Fix #215) better error printing in editor & extension, adds mapping for editor (Closed) Base URL: git@github.com:dart-lang/dart-web-components.git@master
Patch Set: Created 8 years 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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library options; 5 library options;
6 6
7 import 'package:args/args.dart'; 7 import 'package:args/args.dart';
8 8
9 class CompilerOptions { 9 class CompilerOptions {
10 /** Report warnings as errors. */ 10 /** Report warnings as errors. */
(...skipping 13 matching lines...) Expand all
24 24
25 /** File to process by the compiler. */ 25 /** File to process by the compiler. */
26 String inputFile; 26 String inputFile;
27 27
28 /** Directory where all sources are found. */ 28 /** Directory where all sources are found. */
29 final String baseDir; 29 final String baseDir;
30 30
31 /** Directory where all output will be generated. */ 31 /** Directory where all output will be generated. */
32 final String outputDir; 32 final String outputDir;
33 33
34 /**
35 * Whether to print error messages using the json format understood by the
36 * Dart editor.
37 */
38 final bool jsonFormat;
39
34 // We could make this faster, if it ever matters. 40 // We could make this faster, if it ever matters.
35 factory CompilerOptions() => parse(['']); 41 factory CompilerOptions() => parse(['']);
36 42
37 CompilerOptions.fromArgs(ArgResults args) 43 CompilerOptions.fromArgs(ArgResults args)
38 : warningsAsErrors = args['warnings_as_errors'], 44 : warningsAsErrors = args['warnings_as_errors'],
39 verbose = args['verbose'], 45 verbose = args['verbose'],
40 clean = args['clean'], 46 clean = args['clean'],
41 useColors = args['colors'], 47 useColors = args['colors'],
42 baseDir = args['basedir'], 48 baseDir = args['basedir'],
43 outputDir = args['out'], 49 outputDir = args['out'],
44 forceMangle = args['unique_output_filenames'], 50 forceMangle = args['unique_output_filenames'],
51 jsonFormat = args['json_format'],
45 inputFile = args.rest.length > 0 ? args.rest[0] : null; 52 inputFile = args.rest.length > 0 ? args.rest[0] : null;
46 53
47 static CompilerOptions parse(List<String> arguments) { 54 static CompilerOptions parse(List<String> arguments) {
48 var parser = new ArgParser() 55 var parser = new ArgParser()
49 ..addFlag('verbose', abbr: 'v', 56 ..addFlag('verbose', abbr: 'v',
50 defaultsTo: false, negatable: false) 57 defaultsTo: false, negatable: false)
51 ..addFlag('clean', help: 'Remove all generated files', 58 ..addFlag('clean', help: 'Remove all generated files',
52 defaultsTo: false, negatable: false) 59 defaultsTo: false, negatable: false)
53 ..addFlag('warnings_as_errors', abbr: 'e', 60 ..addFlag('warnings_as_errors', abbr: 'e',
54 help: 'Warnings handled as errors', 61 help: 'Warnings handled as errors',
55 defaultsTo: false, negatable: false) 62 defaultsTo: false, negatable: false)
56 ..addFlag('colors', help: 'Display errors/warnings in colored text', 63 ..addFlag('colors', help: 'Display errors/warnings in colored text',
57 defaultsTo: true) 64 defaultsTo: true)
58 ..addFlag('unique_output_filenames', abbr: 'u', 65 ..addFlag('unique_output_filenames', abbr: 'u',
59 help: 'Use unique names for all generated files, so they will not ' 66 help: 'Use unique names for all generated files, so they will not '
60 'have the same name as your input files, even if they are in a ' 67 'have the same name as your input files, even if they are in a '
61 'different directory', 68 'different directory',
62 defaultsTo: false, negatable: false) 69 defaultsTo: false, negatable: false)
70 ..addFlag('json_format', abbr: 'j',
Jennifer Messerly 2012/12/06 04:00:08 I dunno if this one really needs a short option --
Siggi Cherem (dart-lang) 2012/12/06 18:46:42 Done.
71 help: 'Print error messsages in a json format easy to parse by tools,'
72 ' such as the Dart editor',
73 defaultsTo: false, negatable: false)
63 ..addOption('out', abbr: 'o', help: 'Directory where to generate files' 74 ..addOption('out', abbr: 'o', help: 'Directory where to generate files'
64 ' (defaults to the same directory as the source file)') 75 ' (defaults to the same directory as the source file)')
65 ..addOption('basedir', help: 'Base directory where to find all source ' 76 ..addOption('basedir', help: 'Base directory where to find all source '
66 'files (defaults to the source file\'s directory)') 77 'files (defaults to the source file\'s directory)')
67 ..addFlag('help', abbr: 'h', help: 'Displays this help message', 78 ..addFlag('help', abbr: 'h', help: 'Displays this help message',
68 defaultsTo: false, negatable: false); 79 defaultsTo: false, negatable: false);
69 try { 80 try {
70 var results = parser.parse(arguments); 81 var results = parser.parse(arguments);
71 if (results['help'] || results.rest.length == 0) { 82 if (results['help'] || results.rest.length == 0) {
72 showUsage(parser); 83 showUsage(parser);
73 return null; 84 return null;
74 } 85 }
75 return new CompilerOptions.fromArgs(results); 86 return new CompilerOptions.fromArgs(results);
76 } on FormatException catch (e) { 87 } on FormatException catch (e) {
77 print(e.message); 88 print(e.message);
78 showUsage(parser); 89 showUsage(parser);
79 return null; 90 return null;
80 } 91 }
81 } 92 }
82 93
83 static showUsage(parser) { 94 static showUsage(parser) {
84 print('Usage: dwc [options...] input.html'); 95 print('Usage: dwc [options...] input.html');
85 print(parser.getUsage()); 96 print(parser.getUsage());
86 } 97 }
87 } 98 }
OLDNEW
« lib/src/messages.dart ('K') | « lib/src/messages.dart ('k') | test/testing.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698