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

Unified Diff: sdk/lib/_internal/pub_generated/lib/src/command/barback.dart

Issue 805393002: Update pub to use the new command runner API in args. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 11 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
Index: sdk/lib/_internal/pub_generated/lib/src/command/barback.dart
diff --git a/sdk/lib/_internal/pub_generated/lib/src/command/barback.dart b/sdk/lib/_internal/pub_generated/lib/src/command/barback.dart
index 556eb148c50919e107cc153fda0be175614f264a..5fdc519b6abbe369bd9e96a99addbb0489daecf3 100644
--- a/sdk/lib/_internal/pub_generated/lib/src/command/barback.dart
+++ b/sdk/lib/_internal/pub_generated/lib/src/command/barback.dart
@@ -23,10 +23,8 @@ final _allSourceDirectories =
/// Shared base class for [BuildCommand] and [ServeCommand].
abstract class BarbackCommand extends PubCommand {
- final takesArguments = true;
-
/// The build mode.
- BarbackMode get mode => new BarbackMode(commandOptions["mode"]);
+ BarbackMode get mode => new BarbackMode(argResults["mode"]);
/// The directories in the entrypoint package that should be added to the
/// build environment.
@@ -40,24 +38,24 @@ abstract class BarbackCommand extends PubCommand {
List<String> get defaultSourceDirectories;
BarbackCommand() {
- commandParser.addOption(
+ argParser.addOption(
"mode",
defaultsTo: defaultMode.toString(),
help: "Mode to run transformers in.");
- commandParser.addFlag(
+ argParser.addFlag(
"all",
help: "Use all default source directories.",
defaultsTo: false,
negatable: false);
}
- Future onRun() {
+ Future run() {
// Switch to JSON output if specified. We need to do this before parsing
// the source directories so an error will be correctly reported in JSON
// format.
- log.json.enabled = commandOptions.options.contains("format") &&
- commandOptions["format"] == "json";
+ log.json.enabled =
+ argResults.options.contains("format") && argResults["format"] == "json";
_parseSourceDirectories();
return onRunTransformerCommand();
@@ -78,18 +76,18 @@ abstract class BarbackCommand extends PubCommand {
///
/// Throws an exception if the arguments are invalid.
void _parseSourceDirectories() {
- if (commandOptions["all"]) {
+ if (argResults["all"]) {
_addAllDefaultSources();
return;
}
// If no directories were specified, use the defaults.
- if (commandOptions.rest.isEmpty) {
+ if (argResults.rest.isEmpty) {
_addDefaultSources();
return;
}
- sourceDirectories.addAll(commandOptions.rest);
+ sourceDirectories.addAll(argResults.rest);
// Prohibit "lib".
var disallowed = sourceDirectories.where((dir) {
@@ -98,13 +96,14 @@ abstract class BarbackCommand extends PubCommand {
});
if (disallowed.isNotEmpty) {
- usageError(_directorySentence(disallowed, "is", "are", "not allowed"));
+ usageException(
+ _directorySentence(disallowed, "is", "are", "not allowed"));
}
// Make sure the source directories don't reach out of the package.
var invalid = sourceDirectories.where((dir) => !path.isWithin('.', dir));
if (invalid.isNotEmpty) {
- usageError(
+ usageException(
_directorySentence(invalid, "isn't", "aren't", "in this package"));
}
@@ -130,7 +129,7 @@ abstract class BarbackCommand extends PubCommand {
}
if (overlapping.isNotEmpty) {
- usageError(
+ usageException(
_directorySentence(overlapping, "cannot", "cannot", "overlap"));
}
}
@@ -138,8 +137,8 @@ abstract class BarbackCommand extends PubCommand {
/// Handles "--all" by adding all default source directories that are
/// present.
void _addAllDefaultSources() {
- if (commandOptions.rest.isNotEmpty) {
- usageError('Directory names are not allowed if "--all" is passed.');
+ if (argResults.rest.isNotEmpty) {
+ usageException('Directory names are not allowed if "--all" is passed.');
}
// Include every build directory that exists in the package.
« no previous file with comments | « sdk/lib/_internal/pub_generated/lib/src/command.dart ('k') | sdk/lib/_internal/pub_generated/lib/src/command/build.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698