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

Unified Diff: pkg/polymer/lib/builder.dart

Issue 52883002: Remove uses of Options in polymer lint and deploy tools. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/polymer/lib/deploy.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/builder.dart
diff --git a/pkg/polymer/lib/builder.dart b/pkg/polymer/lib/builder.dart
index 11f401bfd5d4608cf5cbc571d97a71458f770608..4750ffddd0e29e1e8d4ff1ab7a97f542a272d340 100644
--- a/pkg/polymer/lib/builder.dart
+++ b/pkg/polymer/lib/builder.dart
@@ -101,7 +101,7 @@ import 'transformer.dart';
* root (for example 'web/index.html'). If null, all files under 'web/' are
* treated as possible entry points.
*
- * Options are read from the command line arguments, but you can override them
+ * Options must be passed by
* passing the [options] argument. The deploy operation is run only when the
* command-line argument `--deploy` is present, or equivalently when
* `options.forceDeploy` is true.
@@ -113,7 +113,12 @@ import 'transformer.dart';
*/
Future build({List<String> entryPoints, CommandLineOptions options,
String currentPackage, Map<String, String> packageDirs}) {
- if (options == null) options = _options;
+ if (options == null) {
+ // The dart:io Options class has been removed, and command-line
+ // arguments are only passed to main, as main(List<String> arguments).
+ throw new UnsupportedError(
+ "polymer builder tools must pass options to build()");
+ }
return lint(entryPoints: entryPoints, options: options,
currentPackage: currentPackage, packageDirs: packageDirs).then((res) {
if (options.forceDeploy) {
@@ -133,8 +138,7 @@ Future build({List<String> entryPoints, CommandLineOptions options,
* root (for example 'web/index.html'). If null, all files under 'web/' are
* treated as possible entry points.
*
- * Options are read from the command line arguments, but you can override them
- * passing the [options] argument.
+ * Options must be passed by passing the [options] argument.
*
* The linter needs to know the name of the [currentPackage] and the location
* where to find the code for any package it depends on ([packageDirs]). This is
@@ -142,7 +146,12 @@ Future build({List<String> entryPoints, CommandLineOptions options,
*/
Future lint({List<String> entryPoints, CommandLineOptions options,
String currentPackage, Map<String, String> packageDirs}) {
- if (options == null) options = _options;
+ if (options == null) {
+ // The dart:io Options class has been removed, and command-line
+ // arguments are only passed to main, as main(List<String> arguments).
+ throw new UnsupportedError(
+ "polymer builder tools must pass options to lint()");
+ }
if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec();
var linterOptions = new TransformOptions(entryPoints: entryPoints);
var formatter = options.machineFormat ? jsonFormatter : consoleFormatter;
@@ -188,8 +197,7 @@ Future lint({List<String> entryPoints, CommandLineOptions options,
* root (for example 'web/index.html'). If null, all files under 'web/' are
* treated as possible entry points.
*
- * Options are read from the command line arguments, but you can override them
- * passing the [options] list.
+ * Options must be passed by passing the [options] list.
*
* The deploy step needs to know the name of the [currentPackage] and the
* location where to find the code for any package it depends on
@@ -198,7 +206,12 @@ Future lint({List<String> entryPoints, CommandLineOptions options,
*/
Future deploy({List<String> entryPoints, CommandLineOptions options,
String currentPackage, Map<String, String> packageDirs}) {
- if (options == null) options = _options;
+ if (options == null) {
+ // The dart:io Options class has been removed, and command-line
+ // arguments are only passed to main, as main(List<String> arguments).
+ throw new UnsupportedError(
+ "polymer builder tools must pass options to lint()");
+ }
if (currentPackage == null) currentPackage = readCurrentPackageFromPubspec();
var transformOptions = new TransformOptions(
@@ -255,9 +268,6 @@ class CommandLineOptions {
this.directlyIncludeJS, this.contentSecurityPolicy);
}
-/** Options parsed directly from the command line arguments. */
-CommandLineOptions _options = parseOptions();
-
/**
* Parse command-line arguments and return a [CommandLineOptions] object. The
* following flags are parsed by this method.
@@ -285,6 +295,10 @@ CommandLineOptions _options = parseOptions();
* it with the `--help` command-line flag.
*/
CommandLineOptions parseOptions([List<String> args]) {
+ if (args == null) {
+ throw new UnsupportedError(
+ "polymer builder tools must pass options from main(List<String> args)");
+ }
var parser = new ArgParser()
..addOption('changed', help: 'The file has changed since the last build.',
allowMultiple: true)
@@ -317,7 +331,7 @@ CommandLineOptions parseOptions([List<String> args]) {
var res;
try {
- res = parser.parse(args == null ? new Options().arguments : args);
+ res = parser.parse(args);
} on FormatException catch (e) {
print(e.message);
showUsage();
« no previous file with comments | « no previous file | pkg/polymer/lib/deploy.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698