]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/App.java
Show better error message when sending fails due to missing pre keys
[signal-cli] / src / main / java / org / asamk / signal / App.java
index d9ffa6222bf8f3cdcce98871643d9d5fd3d38049..cf731ea9ea372fb36fdc8e5e55f2298bd9c5a7a3 100644 (file)
@@ -76,6 +76,10 @@ public class App {
                 .dest("global-dbus-system")
                 .help("Make request via system dbus.")
                 .action(Arguments.storeTrue());
+        parser.addArgument("--bus-name")
+                .dest("global-bus-name")
+                .setDefault(DbusConfig.getBusname())
+                .help("Specify the D-Bus bus name to connect to.");
 
         parser.addArgument("-o", "--output")
                 .help("Choose to output in plain text or JSON")
@@ -95,6 +99,9 @@ public class App {
                 .help("Disable message send log (for resending messages that recipient couldn't decrypt)")
                 .action(Arguments.storeTrue());
 
+        parser.epilog(
+                "The global arguments are shown with 'signal-cli -h' and need to come before the subcommand, while the subcommand-specific arguments (shown with 'signal-cli SUBCOMMAND -h') need to be given after the subcommand.");
+
         var subparsers = parser.addSubparsers().title("subcommands").dest("command");
 
         Commands.getCommandSubparserAttachers().forEach((key, value) -> {
@@ -125,8 +132,9 @@ public class App {
         final var useDbus = Boolean.TRUE.equals(ns.getBoolean("global-dbus"));
         final var useDbusSystem = Boolean.TRUE.equals(ns.getBoolean("global-dbus-system"));
         if (useDbus || useDbusSystem) {
+            final var busName = ns.getString("global-bus-name");
             // If account is null, it will connect to the default object path
-            initDbusClient(command, account, useDbusSystem, commandHandler);
+            initDbusClient(command, account, useDbusSystem, busName, commandHandler);
             return;
         }
 
@@ -283,11 +291,14 @@ public class App {
             commandHandler.handleMultiLocalCommand(command, multiAccountManager);
         } catch (IOException e) {
             throw new IOErrorException("Failed to load local accounts file", e);
+        } catch (AccountCheckException e) {
+            throw new UnexpectedErrorException("Failed to load local accounts file", e);
         }
     }
 
     private RegistrationManager loadRegistrationManager(
-            final String account, final SignalAccountFiles signalAccountFiles
+            final String account,
+            final SignalAccountFiles signalAccountFiles
     ) throws UnexpectedErrorException {
         try {
             return signalAccountFiles.initRegistrationManager(account);
@@ -301,7 +312,8 @@ public class App {
     }
 
     private Manager loadManager(
-            final String account, final SignalAccountFiles signalAccountFiles
+            final String account,
+            final SignalAccountFiles signalAccountFiles
     ) throws CommandException {
         logger.trace("Loading account file for {}", account);
         try {