class LayerDefinitionParser implements CommandLine.ITypeConverter<FileEntriesLayer> {

  @VisibleForTesting
  static FilePermissionsProvider parsePermissionsDirective(String directive) {
    if ("actual".equals(directive)) {
      return new ActualPermissionsProvider();
    }

    String[] spec = directive.split(":", -1);
    FilePermissions filesPermission = FilePermissions.fromOctalString(spec[0]);
    FilePermissions directoriesPermission = FilePermissions.DEFAULT_FOLDER_PERMISSIONS;
    if (spec.length > 1) {
      directoriesPermission = FilePermissions.fromOctalString(spec[1]);
    }
    return new FixedPermissionsProvider(filesPermission, directoriesPermission);
  }

}