From 943308dd59168503699994a369d53e1d290e08d7 Mon Sep 17 00:00:00 2001 From: RatzzFatzz Date: Sun, 19 Mar 2023 11:29:59 +0100 Subject: [PATCH] Add preferred-subtitle parameter --- .../config/ConfigLoader.java | 1 + .../model/ConfigProperty.java | 31 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/config/ConfigLoader.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/config/ConfigLoader.java index 9abab3c..adf87af 100644 --- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/config/ConfigLoader.java +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/config/ConfigLoader.java @@ -28,6 +28,7 @@ public class ConfigLoader { new SetValidator(FORCED_KEYWORDS, false, true), new SetValidator(COMMENTARY_KEYWORDS, false, true), new SetValidator(EXCLUDED_DIRECTORY, false, true), + new SetValidator(PREFERRED_SUBTITLES, false, true), new AttributeConfigValidator(), new CoherentConfigValidator(COHERENT, false), new BooleanValidator(FORCE_COHERENT, false) diff --git a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/model/ConfigProperty.java b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/model/ConfigProperty.java index 58debfd..38f9977 100644 --- a/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/model/ConfigProperty.java +++ b/src/main/java/at/pcgamingfreaks/mkvaudiosubtitlechanger/model/ConfigProperty.java @@ -23,10 +23,26 @@ public enum ConfigProperty { EXCLUDED_DIRECTORY("excluded-directories", "Directories to be excluded, combines with config file", "e", Option.UNLIMITED_VALUES), FORCED_KEYWORDS("forced-keywords", "Additional keywords to identify forced tracks", "fk", Option.UNLIMITED_VALUES), COMMENTARY_KEYWORDS("commentary-keywords", "Additional keywords to identify commentary tracks", "ck", Option.UNLIMITED_VALUES), + PREFERRED_SUBTITLES("preferred-subtitles", "Additional keywords to prefer specific subtitle tracks", "ps", Option.UNLIMITED_VALUES), ARGUMENTS("arguments", "List of arguments", null, 0), VERSION("version", "Display version", "v", 0), HELP("help", "\"For help this is\" - Yoda", "h", 0); + /* + * Verify at startup that there are no duplicated shortParameters. + */ + static { + Set shortParameters = new HashSet<>(); + for (String param : Arrays.stream(ConfigProperty.values()).map(ConfigProperty::abrv).collect(Collectors.toList())) { + if (shortParameters.contains(param)) { + throw new IllegalStateException("It is not allowed to have multiple properties with the same abbreviation!"); + } + if (param != null) { + shortParameters.add(param); + } + } + } + private final String property; private final String description; private final String shortParameter; @@ -47,19 +63,4 @@ public enum ConfigProperty { public int args() { return args; } - - /* - * Verify at startup that there are no duplicated shortParameters. - */ - static { - Set shortParameters = new HashSet<>(); - for (String param: Arrays.stream(ConfigProperty.values()).map(ConfigProperty::abrv).collect(Collectors.toList())) { - if (shortParameters.contains(param)) { - throw new IllegalStateException("It is not allowed to have multiple properties with the same abbreviation!"); - } - if (param != null) { - shortParameters.add(param); - } - } - } }