Search in sources :

Example 1 with FilePreconditions

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();
}
Also used : Path(java.nio.file.Path) DeviceSpec(com.android.bundle.Devices.DeviceSpec) ImmutableSet(com.google.common.collect.ImmutableSet) FilePreconditions(com.android.tools.build.bundletool.model.utils.files.FilePreconditions)

Aggregations

DeviceSpec (com.android.bundle.Devices.DeviceSpec)1 FilePreconditions (com.android.tools.build.bundletool.model.utils.files.FilePreconditions)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Path (java.nio.file.Path)1