package net.pterodactylus.xdcc.main;
+import static com.lexicalscope.jewel.cli.CliFactory.parseArguments;
+
import java.io.File;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import com.google.common.eventbus.AsyncEventBus;
import com.google.common.eventbus.EventBus;
+import com.lexicalscope.jewel.cli.Option;
import org.codehaus.jackson.map.ObjectMapper;
/**
Logger.getLogger(Connection.class.getName()).setLevel(Level.INFO);
Logger.getLogger(Core.class.getName()).setLevel(Level.INFO);
+ Parameters parameters = parseArguments(Parameters.class, arguments);
+
EventBus eventBus = new AsyncEventBus(Executors.newSingleThreadExecutor());
- Configuration configuration = new ObjectMapper().readValue(new File("configuration.json"), Configuration.class);
+ Configuration configuration = new ObjectMapper().readValue(new File(parameters.getConfiguration()), Configuration.class);
Core core = new Core(eventBus, configuration.getTemporaryDirectory(), configuration.getFinalDirectory());
eventBus.register(core);
core.start();
}
+ /**
+ * Defines the command-line parameters.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+ private interface Parameters {
+
+ @Option(longName = "configuration", description = "The configuration file", defaultValue = "configuration.json")
+ String getConfiguration();
+
+ }
+
}