Changed the default config location to /etc/dragoon/config.toml; added a CLI option (-c) to specify a different config file.
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
package tech.bitgoblin;
|
||||
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import tech.bitgoblin.config.Cmd;
|
||||
import tech.bitgoblin.config.Config;
|
||||
import tech.bitgoblin.transcoder.RunTranscoderTask;
|
||||
import tech.bitgoblin.transcoder.Transcoder;
|
||||
@ -12,13 +14,15 @@ import java.util.Timer;
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final String configFile = "~/.config/dragoon.toml";
|
||||
|
||||
private static final int msToMinutes = 60 * 1000;
|
||||
|
||||
public static void main(String[] args) {
|
||||
public static void main(String[] args) throws ParseException {
|
||||
// parse command-line options
|
||||
Cmd cmd = new Cmd(args);
|
||||
|
||||
// read our config file
|
||||
Config c = new Config(configFile);
|
||||
Config c = new Config(cmd.getConfigPath());
|
||||
|
||||
// create new Transcoder object and start the service
|
||||
Transcoder t = new Transcoder(c);
|
||||
Timer timer = new Timer();
|
||||
|
30
src/main/java/tech/bitgoblin/config/Cmd.java
Normal file
30
src/main/java/tech/bitgoblin/config/Cmd.java
Normal file
@ -0,0 +1,30 @@
|
||||
package tech.bitgoblin.config;
|
||||
|
||||
import org.apache.commons.cli.*;
|
||||
|
||||
public class Cmd {
|
||||
|
||||
private String configPath = "/etc/dragoon/config.toml";
|
||||
|
||||
public Cmd(String[] args) throws ParseException {
|
||||
Options options = new Options();
|
||||
|
||||
Option configPath = new Option("c", "configPath", true, "configuration file path (defaults to /etc/dragoon/config.toml)");
|
||||
configPath.setRequired(false);
|
||||
options.addOption(configPath);
|
||||
|
||||
CommandLineParser parser = new DefaultParser();
|
||||
HelpFormatter formatter = new HelpFormatter();
|
||||
CommandLine cmd = parser.parse(options, args);
|
||||
|
||||
// set the configPath variable if the option was passed to the program
|
||||
if (cmd.hasOption("configPath")) {
|
||||
this.configPath = cmd.getOptionValue("configPath");
|
||||
}
|
||||
}
|
||||
|
||||
public String getConfigPath() {
|
||||
return this.configPath;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user