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

Unified Diff: pkg/args/lib/args.dart

Issue 16802002: Moved the Option class to its own file in anticipation of working on it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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/args/lib/src/options.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/args/lib/args.dart
diff --git a/pkg/args/lib/args.dart b/pkg/args/lib/args.dart
index 3898b9fd1aafdbb0b778b8d1f9b6be8f20170b74..9e6252a5a2b681ffba321741056ddd25183cc852 100644
--- a/pkg/args/lib/args.dart
+++ b/pkg/args/lib/args.dart
@@ -257,6 +257,8 @@ library args;
import 'src/parser.dart';
import 'src/usage.dart';
+import 'src/options.dart';
+export 'src/options.dart';
/**
* A class for taking a list of raw command line arguments and parsing out
@@ -377,52 +379,6 @@ class ArgParser {
}
/**
- * A command-line option. Includes both flags and options which take a value.
- */
-class Option {
- final String name;
- final String abbreviation;
- final List<String> allowed;
- final defaultValue;
- final Function callback;
- final String help;
- final Map<String, String> allowedHelp;
- final bool isFlag;
- final bool negatable;
- final bool allowMultiple;
-
- Option(this.name, this.abbreviation, this.help, this.allowed,
- this.allowedHelp, this.defaultValue, this.callback, {this.isFlag,
- this.negatable, this.allowMultiple: false}) {
-
- if (name.isEmpty) {
- throw new ArgumentError('Name cannot be empty.');
- } else if (name.startsWith('-')) {
- throw new ArgumentError('Name $name cannot start with "-".');
- }
-
- // Ensure name does not contain any invalid characters.
- if (_invalidChars.hasMatch(name)) {
- throw new ArgumentError('Name "$name" contains invalid characters.');
- }
-
- if (abbreviation != null) {
- if (abbreviation.length != 1) {
- throw new ArgumentError('Abbreviation must be null or have length 1.');
- } else if(abbreviation == '-') {
- throw new ArgumentError('Abbreviation cannot be "-".');
- }
-
- if (_invalidChars.hasMatch(abbreviation)) {
- throw new ArgumentError('Abbreviation is an invalid character.');
- }
- }
- }
-
- static final _invalidChars = new RegExp(r'''[ \t\r\n"'\\/]''');
-}
-
-/**
* The results of parsing a series of command line arguments using
* [ArgParser.parse()]. Includes the parsed options and any remaining unparsed
* command line arguments.
« no previous file with comments | « no previous file | pkg/args/lib/src/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698