| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library options; | 5 library options; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:args/args.dart'; | 9 import 'package:args/args.dart'; |
| 10 | 10 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 * options/flags, this class can be replaced with a simple [ArgParser] instance. | 236 * options/flags, this class can be replaced with a simple [ArgParser] instance. |
| 237 */ | 237 */ |
| 238 class _CommandLineParser { | 238 class _CommandLineParser { |
| 239 | 239 |
| 240 final List<String> _knownFlags; | 240 final List<String> _knownFlags; |
| 241 final ArgParser _parser; | 241 final ArgParser _parser; |
| 242 | 242 |
| 243 /** Creates a new command line parser */ | 243 /** Creates a new command line parser */ |
| 244 _CommandLineParser() | 244 _CommandLineParser() |
| 245 : _knownFlags = <String>[], | 245 : _knownFlags = <String>[], |
| 246 _parser = new ArgParser(); | 246 _parser = new ArgParser(allowTrailingOptions: true); |
| 247 | 247 |
| 248 | 248 |
| 249 /** | 249 /** |
| 250 * Defines a flag. | 250 * Defines a flag. |
| 251 * | 251 * |
| 252 * See [ArgParser.addFlag()]. | 252 * See [ArgParser.addFlag()]. |
| 253 */ | 253 */ |
| 254 void addFlag(String name, {String abbr, String help, bool defaultsTo: false, | 254 void addFlag(String name, {String abbr, String help, bool defaultsTo: false, |
| 255 bool negatable: true, void callback(bool value), bool hide: false}) { | 255 bool negatable: true, void callback(bool value), bool hide: false}) { |
| 256 _knownFlags.add(name); | 256 _knownFlags.add(name); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 _getNextFlagIndex(args, i) { | 341 _getNextFlagIndex(args, i) { |
| 342 for ( ; i < args.length; ++i) { | 342 for ( ; i < args.length; ++i) { |
| 343 if (args[i].startsWith('--')) { | 343 if (args[i].startsWith('--')) { |
| 344 return i; | 344 return i; |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 return i; | 347 return i; |
| 348 } | 348 } |
| 349 } | 349 } |
| OLD | NEW |