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

Unified Diff: sdk/lib/_internal/pub/lib/src/command.dart

Issue 260963007: Move allowTrailingOptions into ArgParser. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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/lib/src/command.dart
diff --git a/sdk/lib/_internal/pub/lib/src/command.dart b/sdk/lib/_internal/pub/lib/src/command.dart
index 760d5fc659244d60cf79a2c5d9af47c36ed85772..3cfb07ac78e385091cb1ee735d050d2c18dfaffc 100644
--- a/sdk/lib/_internal/pub/lib/src/command.dart
+++ b/sdk/lib/_internal/pub/lib/src/command.dart
@@ -129,12 +129,17 @@ abstract class PubCommand {
/// only needs to be set in leaf commands.
bool get takesArguments => false;
+ /// Override this and return `false` to disallow trailing options from being
+ /// parsed after a non-option argument is parsed.
+ bool get allowTrailingOptions => true;
+
/// Alternate names for this command. These names won't be used in the
/// documentation, but they will work when invoked on the command line.
final aliases = const <String>[];
/// The [ArgParser] for this command.
- final commandParser = new ArgParser();
+ ArgParser get commandParser => _commandParser;
+ ArgParser _commandParser;
/// Subcommands exposed by this command.
///
@@ -150,6 +155,8 @@ abstract class PubCommand {
bool get isOffline => false;
PubCommand() {
+ _commandParser = new ArgParser(allowTrailingOptions: allowTrailingOptions);
+
// Allow "--help" after a command to get command help.
commandParser.addFlag('help', abbr: 'h', negatable: false,
help: 'Print usage information for this command.');
@@ -263,7 +270,7 @@ _initCommands() {
/// Creates the top-level [ArgParser] used to parse the pub command line.
ArgParser _initArgParser() {
- var argParser = new ArgParser();
+ var argParser = new ArgParser(allowTrailingOptions: true);
// Add the global options.
argParser.addFlag('help', abbr: 'h', negatable: false,
« pkg/args/test/trailing_options_test.dart ('K') | « sdk/lib/_internal/pub/bin/pub.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698