mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:49:43 +00:00
[ CLI ] Update experiment parsing
Continuation of https://dart-review.googlesource.com/c/sdk/+/169902 Change-Id: Ia971f75aa81c2b5d8696c35f3d16ff53c29f874a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170460 Reviewed-by: Jonas Jensen <jonasfj@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
parent
6200e47c2d
commit
df9597169a
|
@ -39,13 +39,22 @@ void addExperimentalFlags(ArgParser argParser, bool verbose) {
|
|||
extension EnabledExperimentsArg on ArgResults {
|
||||
List<String> get enabledExperiments {
|
||||
List<String> enabledExperiments = [];
|
||||
// Check to see if the ArgParser which generated this result accepts
|
||||
// --enable-experiment as an option. If so, return the result if it was
|
||||
// provided.
|
||||
if (options.contains(experimentFlagName)) {
|
||||
if (wasParsed(experimentFlagName)) {
|
||||
enabledExperiments = this[experimentFlagName];
|
||||
}
|
||||
} else {
|
||||
String experiments = arguments.firstWhere(
|
||||
(e) => e.startsWith('--enable-experiment'),
|
||||
// In the case where a command uses ArgParser.allowAnything() as its
|
||||
// parser the valid set of options for the command isn't specified and
|
||||
// isn't enforced. Instead, we have to manually parse the arguments to
|
||||
// look for --enable-experiment=. Currently, this path is only taken for
|
||||
// the pub and test commands, as well as when we are trying to send
|
||||
// analytics.
|
||||
final String experiments = arguments.firstWhere(
|
||||
(e) => e.startsWith('--enable-experiment='),
|
||||
orElse: () => null,
|
||||
);
|
||||
if (experiments == null) {
|
||||
|
|
Loading…
Reference in a new issue