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

Unified Diff: sdk/lib/_internal/pub/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
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command.dart ('k') | sdk/lib/_internal/pub/lib/src/command/build.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/command/barback.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command/barback.dart b/sdk/lib/_internal/pub/lib/src/command/barback.dart
index 6f67c39dba3fa12ae5ec07cc6ece7e0c1ad2c407..8175e8f108442d2db5d13df7a02119d23c7a151e 100644
--- a/sdk/lib/_internal/pub/lib/src/command/barback.dart
+++ b/sdk/lib/_internal/pub/lib/src/command/barback.dart
@@ -24,10 +24,8 @@ final _allSourceDirectories = new Set<String>.from([
/// 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.
@@ -41,20 +39,20 @@ abstract class BarbackCommand extends PubCommand {
List<String> get defaultSourceDirectories;
BarbackCommand() {
- commandParser.addOption("mode", defaultsTo: defaultMode.toString(),
+ argParser.addOption("mode", defaultsTo: defaultMode.toString(),
help: "Mode to run transformers in.");
- commandParser.addFlag("all",
+ 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();
@@ -75,18 +73,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) {
@@ -95,13 +93,13 @@ 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(_directorySentence(invalid, "isn't", "aren't",
+ usageException(_directorySentence(invalid, "isn't", "aren't",
"in this package"));
}
@@ -127,7 +125,7 @@ abstract class BarbackCommand extends PubCommand {
}
if (overlapping.isNotEmpty) {
- usageError(_directorySentence(overlapping, "cannot", "cannot",
+ usageException(_directorySentence(overlapping, "cannot", "cannot",
"overlap"));
}
}
@@ -135,8 +133,8 @@ abstract class BarbackCommand extends PubCommand {
/// Handles "--all" by adding all default source directories that are
/// present.
void _addAllDefaultSources() {
- if (commandOptions.rest.isNotEmpty) {
- usageError(
+ if (argResults.rest.isNotEmpty) {
+ usageException(
'Directory names are not allowed if "--all" is passed.');
}
« no previous file with comments | « sdk/lib/_internal/pub/lib/src/command.dart ('k') | sdk/lib/_internal/pub/lib/src/command/build.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698