blob: df8ed0f3496403991c05b01bce74e6d11ce94c6f [file] [log] [blame]
// Copyright (c) 2021, 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.
import 'dart:io';
import 'package:args/args.dart';
class BaselineOptions {
late final bool ignoreUnmapped;
late final bool dryRun;
late final List<String> builders;
late final Map<String, String> configs;
late final List<String> channels;
late final Set<String> suites;
late final String target;
BaselineOptions(List<String> arguments) {
var parser = ArgParser();
parser.addMultiOption('channel',
abbr: 'c',
allowed: ['main', 'dev', 'beta', 'stable'],
defaultsTo: ['main'],
help: 'a comma separated list of channels');
parser.addMultiOption('config-mapping',
abbr: 'm',
help: 'a comma separated list of configuration mappings in the form:'
'<old1>:<new1>,<old2>:<new2>');
parser.addMultiOption('builders',
abbr: 'b',
help: 'a comma separated list of builders to read result data from');
parser.addMultiOption('suites',
abbr: 's', help: 'a comma separated list of test suites to include');
parser.addOption('target',
abbr: 't', help: 'a the name of the builder to baseline');
parser.addFlag('dry-run',
abbr: 'n',
defaultsTo: false,
help: 'prevents writes and only processes a single result',
negatable: false);
parser.addFlag('ignore-unmapped',
abbr: 'u',
defaultsTo: false,
help: 'ignore tests in unmapped configurations',
negatable: false);
parser.addFlag('help',
abbr: 'h', negatable: false, help: 'prints this message');
var parsed = parser.parse(arguments);
if (parsed['help'] ||
parsed['builders'] is! List<String> ||
parsed['target'] is! String) {
print(parser.usage);
exit(64);
}
builders = (parsed['builders'] as List<String>);
configs = {
for (var v in ((parsed['config-mapping'] as Iterable<String>)
.map((c) => c.split(':'))))
v[0]: v[1]
};
ignoreUnmapped = parsed['ignore-unmapped'];
dryRun = parsed['dry-run'];
channels = parsed['channel'];
suites = Set.unmodifiable(parsed['suites']);
target = parsed['target'];
}
}