use of com.android.tools.build.bundletool.model.utils.files.FilePreconditions in project bundletool by google.
the class GetSizeCommand method fromFlags.
public static GetSizeCommand fromFlags(ParsedFlags flags) {
Path apksArchivePath = APKS_ARCHIVE_FILE_FLAG.getRequiredValue(flags);
Optional<Path> deviceSpecPath = DEVICE_SPEC_FLAG.getValue(flags);
Optional<ImmutableSet<String>> modules = MODULES_FLAG.getValue(flags);
Optional<Boolean> instant = INSTANT_FLAG.getValue(flags);
Optional<Boolean> pretty = HUMAN_READABLE_SIZES_FLAG.getValue(flags);
ImmutableSet<Dimension> dimensions = DIMENSIONS_FLAG.getValue(flags).orElse(ImmutableSet.of());
flags.checkNoUnknownFlags();
checkFileExistsAndReadable(apksArchivePath);
deviceSpecPath.ifPresent(FilePreconditions::checkFileExistsAndReadable);
DeviceSpec deviceSpec = deviceSpecPath.map(DeviceSpecParser::parsePartialDeviceSpec).orElse(DeviceSpec.getDefaultInstance());
GetSizeCommand.Builder command = builder().setApksArchivePath(apksArchivePath).setDeviceSpec(deviceSpec).setGetSizeSubCommand(parseGetSizeSubCommand(flags));
modules.ifPresent(command::setModules);
instant.ifPresent(command::setInstant);
pretty.ifPresent(command::setHumanReadableSizes);
if (dimensions.contains(Dimension.ALL)) {
dimensions = SUPPORTED_DIMENSIONS;
}
command.setDimensions(dimensions);
return command.build();
}
Aggregations