]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/App.java
Remove fallbacks to deprecated data paths
[signal-cli] / src / main / java / org / asamk / signal / App.java
index 521e453a3e58692c5bc3e092e0e89f42d8330825..9e410d2f10c96df4bbd79f024f2a5f319d56622a 100644 (file)
@@ -35,6 +35,8 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import static net.sourceforge.argparse4j.DefaultSettings.VERSION_0_9_0_DEFAULT_SETTINGS;
+
 public class App {
 
     private final static Logger logger = LoggerFactory.getLogger(App.class);
@@ -42,7 +44,8 @@ public class App {
     private final Namespace ns;
 
     static ArgumentParser buildArgumentParser() {
-        var parser = ArgumentParsers.newFor("signal-cli")
+        var parser = ArgumentParsers.newFor("signal-cli", VERSION_0_9_0_DEFAULT_SETTINGS)
+                .includeArgumentNamesAsKeysInResult(true)
                 .build()
                 .defaultHelp(true)
                 .description("Commandline interface for Signal.")
@@ -67,7 +70,7 @@ public class App {
                 .setDefault(OutputType.PLAIN_TEXT);
 
         parser.addArgument("--service-environment")
-                .help("Choose the server environment to use, SANDBOX or LIVE.")
+                .help("Choose the server environment to use.")
                 .type(Arguments.enumStringType(ServiceEnvironmentCli.class))
                 .setDefault(ServiceEnvironmentCli.LIVE);
 
@@ -101,7 +104,7 @@ public class App {
         var username = ns.getString("username");
 
         final var useDbus = ns.getBoolean("dbus");
-        final var useDbusSystem = ns.getBoolean("dbus_system");
+        final var useDbusSystem = ns.getBoolean("dbus-system");
         if (useDbus || useDbusSystem) {
             // If username is null, it will connect to the default object path
             initDbusClient(command, username, useDbusSystem);
@@ -116,7 +119,7 @@ public class App {
             dataPath = getDefaultDataPath();
         }
 
-        final var serviceEnvironmentCli = ns.<ServiceEnvironmentCli>get("service_environment");
+        final var serviceEnvironmentCli = ns.<ServiceEnvironmentCli>get("service-environment");
         final var serviceEnvironment = serviceEnvironmentCli == ServiceEnvironmentCli.LIVE
                 ? ServiceEnvironment.LIVE
                 : ServiceEnvironment.SANDBOX;
@@ -302,32 +305,9 @@ public class App {
     }
 
     /**
-     * Uses $XDG_DATA_HOME/signal-cli if it exists, or if none of the legacy directories exist:
-     * - $HOME/.config/signal
-     * - $HOME/.config/textsecure
-     *
-     * @return the data directory to be used by signal-cli.
+     * @return the default data directory to be used by signal-cli.
      */
     private static File getDefaultDataPath() {
-        var dataPath = new File(IOUtils.getDataHomeDir(), "signal-cli");
-        if (dataPath.exists()) {
-            return dataPath;
-        }
-
-        var configPath = new File(System.getProperty("user.home"), ".config");
-
-        var legacySettingsPath = new File(configPath, "signal");
-        if (legacySettingsPath.exists()) {
-            logger.warn("Using legacy data path \"{}\", please move it to \"{}\".", legacySettingsPath, dataPath);
-            return legacySettingsPath;
-        }
-
-        legacySettingsPath = new File(configPath, "textsecure");
-        if (legacySettingsPath.exists()) {
-            logger.warn("Using legacy data path \"{}\", please move it to \"{}\".", legacySettingsPath, dataPath);
-            return legacySettingsPath;
-        }
-
-        return dataPath;
+        return new File(IOUtils.getDataHomeDir(), "signal-cli");
     }
 }