mirror of
https://github.com/RatzzFatzz/MKVAudioSubtitleChanger.git
synced 2026-02-11 02:05:56 +01:00
Add cli property for forced keywords
This commit is contained in:
@@ -3,9 +3,13 @@ package at.pcgamingfreaks.mkvaudiosubtitlechanger;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.config.Config;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.MkvFileCollector;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.impl.MkvFileProcessor;
|
||||
import at.pcgamingfreaks.mkvaudiosubtitlechanger.model.ConfigProperty;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.commons.cli.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static at.pcgamingfreaks.mkvaudiosubtitlechanger.model.ConfigProperty.*;
|
||||
import static java.lang.Integer.parseInt;
|
||||
|
||||
@Log4j2
|
||||
@@ -18,11 +22,12 @@ public class Main {
|
||||
|
||||
private static void initConfig(String[] args) {
|
||||
Options options = new Options();
|
||||
options.addOption("h", "help", false, "\"for help this is\" - Yoda");
|
||||
options.addRequiredOption("l", "library", true, "path to library");
|
||||
options.addOption("c", "config", false, "path to config");
|
||||
options.addOption("t", "threads", true, "thread count");
|
||||
options.addOption("s", "safe-mode", false, "Test run (no files will be changes)");
|
||||
options.addOption("h", HELP.toString(), false, "\"for help this is\" - Yoda");
|
||||
options.addRequiredOption("l", LIBRARY.toString(), true, "path to library");
|
||||
options.addOption("c", CONFIG.toString(), false, "path to config");
|
||||
options.addOption("t", THREADS.toString(), true, "thread count");
|
||||
options.addOption("s", SAFE_MODE.toString(), false, "Test run (no files will be changes)");
|
||||
options.addOption(create("k", FORCED_KEYWORDS.toString(),Option.UNLIMITED_VALUES,"Additional keywords to identify forced tracks"));
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
@@ -35,10 +40,11 @@ public class Main {
|
||||
}
|
||||
|
||||
Config config = Config.getInstance();
|
||||
config.loadConfig(cmd.getOptionValue("config", "config.yaml")); // use cmd input
|
||||
config.loadConfig(cmd.getOptionValue(CONFIG.toString(), "config.yaml")); // use cmd input
|
||||
config.setLibraryPath(cmd.getOptionValue("library"));
|
||||
if (cmd.hasOption("threads")) config.setThreadCount(parseInt(cmd.getOptionValue("threads")));
|
||||
config.setSafeMode(cmd.hasOption("safe-mode"));
|
||||
if (cmd.hasOption("threads")) config.setThreadCount(parseInt(cmd.getOptionValue("threads")));
|
||||
if (cmd.hasOption(FORCED_KEYWORDS.toString())) config.getForcedKeywords().addAll(List.of(cmd.getOptionValues(FORCED_KEYWORDS.toString())));
|
||||
config.isValid();
|
||||
} catch (ParseException e) {
|
||||
log.error(e);
|
||||
@@ -46,4 +52,11 @@ public class Main {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static Option create(String opt, String longOpt, int args, String desc) {
|
||||
Option option = new Option(opt, desc);
|
||||
option.setLongOpt(longOpt);
|
||||
option.setArgs(args);
|
||||
return option;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user