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

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

Issue 814113004: Pull args, intl, logging, shelf, and source_maps out of the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also csslib. Created 6 years 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 | « pkg/args/lib/src/arg_parser.dart ('k') | pkg/args/lib/src/help_command.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/args/lib/src/arg_results.dart
diff --git a/pkg/args/lib/src/arg_results.dart b/pkg/args/lib/src/arg_results.dart
deleted file mode 100644
index 815d8dd76f50035f5ea8bfa890cd92f9df94b6e4..0000000000000000000000000000000000000000
--- a/pkg/args/lib/src/arg_results.dart
+++ /dev/null
@@ -1,96 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library args.src.arg_results;
-
-import 'package:collection/wrappers.dart';
-
-import 'arg_parser.dart';
-
-/// Creates a new [ArgResults].
-///
-/// Since [ArgResults] doesn't have a public constructor, this lets [Parser]
-/// get to it. This function isn't exported to the public API of the package.
-ArgResults newArgResults(ArgParser parser, Map<String, dynamic> parsed,
- String name, ArgResults command, List<String> rest,
- List<String> arguments) {
- return new ArgResults._(parser, parsed, name, command, rest, arguments);
-}
-
-/// The results of parsing a series of command line arguments using
-/// [ArgParser.parse()].
-///
-/// Includes the parsed options and any remaining unparsed command line
-/// arguments.
-class ArgResults {
- /// The [ArgParser] whose options were parsed for these results.
- final ArgParser _parser;
-
- /// The option values that were parsed from arguments.
- final Map<String, dynamic> _parsed;
-
- /// If these are the results for parsing a command's options, this will be the
- /// name of the command. For top-level results, this returns `null`.
- final String name;
-
- /// The command that was selected, or `null` if none was.
- ///
- /// This will contain the options that were selected for that command.
- final ArgResults command;
-
- /// The remaining command-line arguments that were not parsed as options or
- /// flags.
- ///
- /// If `--` was used to separate the options from the remaining arguments,
- /// it will not be included in this list unless parsing stopped before the
- /// `--` was reached.
- final List<String> rest;
-
- /// The original list of arguments that were parsed.
- final List<String> arguments;
-
- /// Creates a new [ArgResults].
- ArgResults._(this._parser, this._parsed, this.name, this.command,
- List<String> rest, List<String> arguments)
- : this.rest = new UnmodifiableListView(rest),
- this.arguments = new UnmodifiableListView(arguments);
-
- /// Gets the parsed command-line option named [name].
- operator [](String name) {
- if (!_parser.options.containsKey(name)) {
- throw new ArgumentError('Could not find an option named "$name".');
- }
-
- return _parser.options[name].getOrDefault(_parsed[name]);
- }
-
- /// Get the names of the available options as an [Iterable].
- ///
- /// This includes the options whose values were parsed or that have defaults.
- /// Options that weren't present and have no default will be omitted.
- Iterable<String> get options {
- var result = new Set.from(_parsed.keys);
-
- // Include the options that have defaults.
- _parser.options.forEach((name, option) {
- if (option.defaultValue != null) result.add(name);
- });
-
- return result;
- }
-
- /// Returns `true` if the option with [name] was parsed from an actual
- /// argument.
- ///
- /// Returns `false` if it wasn't provided and the default value or no default
- /// value would be used instead.
- bool wasParsed(String name) {
- var option = _parser.options[name];
- if (option == null) {
- throw new ArgumentError('Could not find an option named "$name".');
- }
-
- return _parsed.containsKey(name);
- }
-}
« no previous file with comments | « pkg/args/lib/src/arg_parser.dart ('k') | pkg/args/lib/src/help_command.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698