mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Rework app to use picocli
This commit is contained in:
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.DefaultParser;
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@@ -18,7 +19,7 @@ import java.util.regex.Pattern;
|
||||
@Slf4j
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@NoArgsConstructor
|
||||
public class Config {
|
||||
@Getter(AccessLevel.NONE)
|
||||
@Setter(AccessLevel.NONE)
|
||||
@@ -27,25 +28,40 @@ public class Config {
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
@Getter(AccessLevel.NONE)
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
|
||||
private File configPath;
|
||||
@CommandLine.Option(names = {"-l", "--library"}, required = true, description = "path to library")
|
||||
private File libraryPath;
|
||||
@Getter(AccessLevel.NONE)
|
||||
@CommandLine.Option(names = {"-m", "--mkvtoolnix"}, defaultValue = "C:\\Program Files\\MKVToolNix", description = "path to mkvtoolnix installation")
|
||||
private File mkvToolNix;
|
||||
|
||||
@CommandLine.Option(names = {"-t", "--threads"}, defaultValue = "2", description = "thread count (default: 2)")
|
||||
private int threads;
|
||||
@CommandLine.Option(names = {"-i", "--include-pattern"}, defaultValue = ".*", description = "include files matching pattern (default: \".*\")")
|
||||
private Pattern includePattern;
|
||||
@CommandLine.Option(names = {"-s", "--safemode"}, description = "test run (no files will be changes)")
|
||||
private boolean safeMode;
|
||||
|
||||
@CommandLine.Option(names = {"-c", "--coherent"}, description = "try to match all files in dir of depth with the same attribute config")
|
||||
private Integer coherent;
|
||||
@CommandLine.Option(names = {"-cf", "--force-coherent"}, description = "changes are only applied if it's a coherent match")
|
||||
private boolean forceCoherent;
|
||||
@CommandLine.Option(names = {"-n"}, description = "sets filter-date to last successful execution (overwrites input of filter-date)")
|
||||
private boolean onlyNewFiles;
|
||||
@CommandLine.Option(names = {"-d", "--filter-date"}, defaultValue = CommandLine.Option.NULL_VALUE, description = "only consider files created newer than entered date (format: \"dd.MM.yyyy-HH:mm:ss\")")
|
||||
private Date filterDate;
|
||||
|
||||
@CommandLine.Option(names = {"-fk", "--force-keywords"}, description = "Additional keywords to identify forced tracks")
|
||||
private Set<String> forcedKeywords = new HashSet<>(Arrays.asList("forced", "signs", "songs"));
|
||||
@CommandLine.Option(names = {"-ck", "--commentary-keywords"}, description = "Additional keywords to identify commentary tracks")
|
||||
private Set<String> commentaryKeywords = new HashSet<>(Arrays.asList("commentary", "director"));
|
||||
@CommandLine.Option(names = {"-e", "--excluded-directory"}, description = "Directories to be excluded, combines with config file")
|
||||
private Set<String> excludedDirectories = new HashSet<>();
|
||||
@CommandLine.Option(names = {"-ps", "--preferred-subtiltes"}, description = "Additional keywords to prefer specific subtitle tracks")
|
||||
private Set<String> preferredSubtitles = new HashSet<>(Arrays.asList("unstyled"));
|
||||
|
||||
@CommandLine.Option(names = {"-a"}, required = true, arity = "1..*", converter = AttributeConfigConverter.class)
|
||||
private List<AttributeConfig> attributeConfig;
|
||||
|
||||
public static Config getInstance() {
|
||||
@@ -59,6 +75,10 @@ public class Config {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static void setInstance(Config c) {
|
||||
config = c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get path to specific mkvtoolnix application.
|
||||
*
|
||||
@@ -66,7 +86,7 @@ public class Config {
|
||||
*/
|
||||
public String getPathFor(MkvToolNix application) {
|
||||
return mkvToolNix.getAbsolutePath().endsWith("/") ? mkvToolNix.getAbsolutePath() + application :
|
||||
mkvToolNix.getAbsolutePath() + "/" + application;
|
||||
mkvToolNix.getAbsolutePath() + "/" + application;
|
||||
}
|
||||
|
||||
public String getNormalizedLibraryPath() {
|
||||
|
||||
Reference in New Issue
Block a user