BuildFilter.fromArg constructor
Builds a BuildFilter from a command line argument.
Both relative paths and package: uris are supported. Relative
paths are treated as relative to the rootPackage
.
Globs are supported in package names and paths.
Implementation
factory BuildFilter.fromArg(String arg, String rootPackage) {
var uri = Uri.parse(arg);
if (uri.scheme == 'package') {
var package = uri.pathSegments.first;
var glob = Glob(p.url.joinAll([
'lib',
...uri.pathSegments.skip(1),
]));
return BuildFilter(Glob(package), glob);
} else if (uri.scheme.isEmpty) {
return BuildFilter(Glob(rootPackage), Glob(uri.path));
} else {
throw FormatException('Unsupported scheme ${uri.scheme}', uri);
}
}