Chromium Code Reviews| Index: lib/src/options.dart |
| diff --git a/lib/src/options.dart b/lib/src/options.dart |
| index cf6aaa6300b91ade67cf0ac39fb50c3b3b99c870..ca6e1c75a53a388353e2e002aa393f6a820b3487 100644 |
| --- a/lib/src/options.dart |
| +++ b/lib/src/options.dart |
| @@ -56,6 +56,11 @@ class SourceResolverOptions { |
| this.useImplicitHtml: false}); |
| } |
| +enum ModuleFormat { es6, dart } |
|
Jennifer Messerly
2016/01/22 18:29:01
Heh, not sure the enum adds much value. More an is
ochafik
2016/01/23 12:24:18
I agree, *if only* we had Java enums...
|
| + |
| +ModuleFormat parseModuleFormat(String s) => |
| + ModuleFormat.values.firstWhere((v) => s == '$v'.split('.')[1]); |
|
Jennifer Messerly
2016/01/22 18:29:01
if parsing fails, are we okay because args option
ochafik
2016/01/23 12:24:18
Yes we are, but cleaned up utils (moved to utils.d
|
| + |
| // TODO(jmesserly): refactor all codegen options here. |
| class CodegenOptions { |
| /// Whether to emit the source map files. |
| @@ -79,7 +84,7 @@ class CodegenOptions { |
| /// Which module format to support. |
| /// Currently 'es6' and 'dart' are supported. |
| - final String moduleFormat; |
| + final ModuleFormat moduleFormat; |
| const CodegenOptions( |
| {this.emitSourceMaps: true, |
| @@ -88,7 +93,7 @@ class CodegenOptions { |
| this.destructureNamedParams: _DESTRUCTURE_NAMED_PARAMS_DEFAULT, |
| this.outputDir, |
| this.arrowFnBindThisWorkaround: false, |
| - this.moduleFormat: 'dart'}); |
| + this.moduleFormat: ModuleFormat.dart}); |
| } |
| /// Options for devrun. |
| @@ -158,7 +163,7 @@ class CompilerOptions { |
| /// to this directory. |
| final String inputBaseDir; |
| - CompilerOptions( |
| + const CompilerOptions( |
| {this.sourceOptions: const SourceResolverOptions(), |
| this.codegenOptions: const CodegenOptions(), |
| this.runnerOptions: const RunnerOptions(), |
| @@ -239,7 +244,7 @@ CompilerOptions parseOptions(List<String> argv, {bool forceOutDir: false}) { |
| destructureNamedParams: args['destructure-named-params'], |
| outputDir: outputDir, |
| arrowFnBindThisWorkaround: args['arrow-fn-bind-this'], |
| - moduleFormat: args['modules']), |
| + moduleFormat: parseModuleFormat(args['modules'])), |
| sourceOptions: new SourceResolverOptions( |
| useMockSdk: args['mock-sdk'], |
| dartSdkPath: sdkPath, |
| @@ -309,7 +314,7 @@ final ArgParser argParser = new ArgParser() |
| allowed: ['es6', 'dart'], |
| allowedHelp: { |
| 'es6': 'es6 modules', |
| - 'custom-dart': 'a custom format used by dartdevc, similar to AMD' |
| + 'dart': 'a custom format used by dartdevc, similar to AMD' |
|
Jennifer Messerly
2016/01/22 18:29:01
Hmmm, I don't like calling this format "dart" ...
ochafik
2016/01/23 12:24:17
Done (+ tied these values to the enum with a getEn
|
| }, |
| defaultsTo: 'dart') |