diff --git a/src/main/java/io/bitsquare/app/AppModule.java b/src/main/java/io/bitsquare/app/AppModule.java index 025e23c2ac..e2d802fa3c 100644 --- a/src/main/java/io/bitsquare/app/AppModule.java +++ b/src/main/java/io/bitsquare/app/AppModule.java @@ -42,6 +42,7 @@ import net.tomp2p.connection.Ports; * Configures all non-UI modules necessary to run a Bitsquare application. */ public class AppModule extends BitsquareModule { + public static final String APP_NAME_KEY = "name"; public AppModule(Properties properties) { super(properties); @@ -59,7 +60,7 @@ public class AppModule extends BitsquareModule { install(tradeModule()); install(offerModule()); - String appName = properties.getProperty(ArgumentParser.NAME_FLAG); + String appName = properties.getProperty(APP_NAME_KEY); Preconditions.checkArgument(appName != null, "App name must be non-null"); bindConstant().annotatedWith(Names.named("appName")).to(appName); diff --git a/src/main/java/io/bitsquare/app/ArgumentParser.java b/src/main/java/io/bitsquare/app/ArgumentParser.java index ebac781b87..506435e7a3 100644 --- a/src/main/java/io/bitsquare/app/ArgumentParser.java +++ b/src/main/java/io/bitsquare/app/ArgumentParser.java @@ -21,12 +21,11 @@ import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParserException; import net.sourceforge.argparse4j.inf.Namespace; +import static io.bitsquare.app.AppModule.APP_NAME_KEY; import static io.bitsquare.msg.MessageModule.*; public class ArgumentParser { - public static final String NAME_FLAG = "name"; - private final net.sourceforge.argparse4j.inf.ArgumentParser parser; public ArgumentParser() { @@ -43,7 +42,7 @@ public class ArgumentParser { .help("Seed node port"); // Args for app config - parser.addArgument("-n", "--" + NAME_FLAG) + parser.addArgument("-n", "--" + APP_NAME_KEY) .help("Name to append to default application name"); } diff --git a/src/main/java/io/bitsquare/app/gui/Main.java b/src/main/java/io/bitsquare/app/gui/Main.java index a40c4f5d2d..2aedf903a9 100644 --- a/src/main/java/io/bitsquare/app/gui/Main.java +++ b/src/main/java/io/bitsquare/app/gui/Main.java @@ -49,7 +49,7 @@ import org.slf4j.LoggerFactory; import lighthouse.files.AppDirectory; import net.sourceforge.argparse4j.inf.Namespace; -import static io.bitsquare.app.ArgumentParser.NAME_FLAG; +import static io.bitsquare.app.AppModule.APP_NAME_KEY; import static io.bitsquare.msg.MessageModule.*; public class Main extends Application { @@ -63,12 +63,12 @@ public class Main extends Application { public static void main(String[] args) { Namespace argumentsNamespace = new ArgumentParser().parseArgs(args); - if (argumentsNamespace.getString(NAME_FLAG) != null) - appName = appName + "-" + argumentsNamespace.getString(NAME_FLAG); + if (argumentsNamespace.getString(APP_NAME_KEY) != null) + appName = appName + "-" + argumentsNamespace.getString(APP_NAME_KEY); properties = ConfigLoader.loadConfig(appName); - properties.setProperty(NAME_FLAG, appName); + properties.setProperty(APP_NAME_KEY, appName); if (argumentsNamespace.getString(BOOTSTRAP_NODE_ID_KEY) != null) properties.setProperty(BOOTSTRAP_NODE_ID_KEY, argumentsNamespace.getString(BOOTSTRAP_NODE_ID_KEY)); diff --git a/src/test/java/io/bitsquare/app/gui/ViewLoaderTests.java b/src/test/java/io/bitsquare/app/gui/ViewLoaderTests.java index 3285799b6d..b766d5aab0 100644 --- a/src/test/java/io/bitsquare/app/gui/ViewLoaderTests.java +++ b/src/test/java/io/bitsquare/app/gui/ViewLoaderTests.java @@ -17,7 +17,6 @@ package io.bitsquare.app.gui; -import io.bitsquare.app.ArgumentParser; import io.bitsquare.gui.FatalException; import io.bitsquare.gui.Navigation; import io.bitsquare.gui.ViewLoader; @@ -35,6 +34,8 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import static io.bitsquare.app.AppModule.APP_NAME_KEY; + public class ViewLoaderTests { public static class TestApp extends Application { @@ -63,7 +64,7 @@ public class ViewLoaderTests { @Before public void setUp() { Properties properties = new Properties(); - properties.setProperty(ArgumentParser.NAME_FLAG, "testApp"); + properties.setProperty(APP_NAME_KEY, "testApp"); Injector injector = Guice.createInjector(new MainModule(properties, TestApp.primaryStage)); ViewLoader.setInjector(injector); }