Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/main/java/me/itzg/helpers/McImageHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import me.itzg.helpers.assertcmd.AssertCommand;
Expand Down Expand Up @@ -36,14 +43,6 @@
import picocli.CommandLine.IVersionProvider;
import picocli.CommandLine.Option;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.util.jar.Manifest;

@Command(name = "mc-image-helper",
versionProvider = McImageHelper.AppVersionProvider.class,
subcommands = {
Expand Down Expand Up @@ -74,7 +73,12 @@
@Slf4j
public class McImageHelper {

//language=RegExp
public static final String OPTION_SPLIT_COMMAS = "\\s*,\\s*";
//language=RegExp
public static final String SPLIT_COMMA_NL = "[,\\n]";
public static final String SPLIT_SYNOPSIS_COMMA_NL = ",|<nl>";
//language=RegExp
public static final String VERSION_REGEX = "\\d+(\\.\\d+)+";

@SuppressWarnings("unused")
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/me/itzg/helpers/sync/MulitCopyCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package me.itzg.helpers.sync;

import static me.itzg.helpers.McImageHelper.SPLIT_COMMA_NL;
import static me.itzg.helpers.McImageHelper.SPLIT_SYNOPSIS_COMMA_NL;

import java.io.IOException;
import java.net.URI;
import java.nio.file.DirectoryStream;
Expand Down Expand Up @@ -58,7 +61,7 @@ public class MulitCopyCommand implements Callable<Integer> {
@Option(names = "--skip-existing", defaultValue = "false")
boolean skipExisting;

@Parameters(split = ",|\\n", splitSynopsisLabel = ",|<nl>", arity = "1..*",
@Parameters(split = SPLIT_COMMA_NL, splitSynopsisLabel = SPLIT_SYNOPSIS_COMMA_NL, arity = "1..*",
paramLabel = "SRC",
description = "Any mix of source file, directory, or URLs."
+ "%nCan be optionally comma or newline separated."
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
package me.itzg.helpers.vanillatweaks;

import static me.itzg.helpers.McImageHelper.SPLIT_COMMA_NL;
import static me.itzg.helpers.McImageHelper.SPLIT_SYNOPSIS_COMMA_NL;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.itzg.helpers.errors.GenericException;
import me.itzg.helpers.errors.InvalidParameterException;
import me.itzg.helpers.files.Manifests;
import me.itzg.helpers.http.*;
import me.itzg.helpers.http.FailedRequestException;
import me.itzg.helpers.http.Fetch;
import me.itzg.helpers.http.SharedFetch;
import me.itzg.helpers.http.SharedFetchArgs;
import me.itzg.helpers.http.Uris;
import me.itzg.helpers.json.ObjectMappers;
import me.itzg.helpers.singles.MoreCollections;
import me.itzg.helpers.vanillatweaks.model.PackDefinition;
Expand All @@ -22,24 +48,6 @@
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import static me.itzg.helpers.McImageHelper.OPTION_SPLIT_COMMAS;

@Command(name = "vanillatweaks", description = "Downloads Vanilla Tweaks resource packs, data packs, or crafting tweaks"
+ " given a share code or pack file")
@Slf4j
Expand All @@ -49,10 +57,14 @@ public class VanillaTweaksCommand implements Callable<Integer> {
public static final String MANIFEST_ID = "vanillatweaks";
private static final int FINGERPRINT_LENGTH = 7;

@Option(names = "--share-codes", required = true, split = OPTION_SPLIT_COMMAS, paramLabel = "CODE")
@Option(names = "--share-codes", split = SPLIT_COMMA_NL, splitSynopsisLabel = SPLIT_SYNOPSIS_COMMA_NL,
paramLabel = "CODE"
)
List<String> shareCodes;

@Option(names = "--pack-files", split = OPTION_SPLIT_COMMAS, paramLabel = "FILE")
@Option(names = "--pack-files", split = SPLIT_COMMA_NL, splitSynopsisLabel = SPLIT_SYNOPSIS_COMMA_NL,
paramLabel = "FILE"
)
List<Path> packFiles;

@Option(names = "--output-directory", defaultValue = ".", paramLabel = "DIR")
Expand Down