about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-06-05 15:12:09 +0200
committerGitHub <noreply@github.com>2019-06-05 15:12:09 +0200
commitf0c3e4195cf9c85dac72b8c44e755b67d5120fac (patch)
treedbf69885e9f78f6acaf7234d9e30b5e82bb01e9b /src/command
parentc03f9363902fbea96c8a2d35c945b52b27c3f701 (diff)
parent4e972f8aef4a514928e7ffd56e8d31c7bef37b13 (diff)
downloadprofani-tty-f0c3e4195cf9c85dac72b8c44e755b67d5120fac.tar.gz
Merge pull request #1113 from profanity-im/fix/1112-autoconnect
Check autoconnect set settings
Diffstat (limited to 'src/command')
-rw-r--r--src/command/cmd_funcs.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 999afd10..f2c9aa1d 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -6555,12 +6555,20 @@ cmd_autoconnect(ProfWin *window, const char *const command, gchar **args)
         prefs_set_string(PREF_CONNECT_ACCOUNT, NULL);
         cons_show("Autoconnect account disabled.");
     } else if (strcmp(args[0], "set") == 0) {
-        prefs_set_string(PREF_CONNECT_ACCOUNT, args[1]);
-        cons_show("Autoconnect account set to: %s.", args[1]);
+        if (args[1] == NULL || strlen(args[1]) == 0) {
+            cons_bad_cmd_usage(command);
+        } else {
+            if (accounts_account_exists(args[1])) {
+                prefs_set_string(PREF_CONNECT_ACCOUNT, args[1]);
+                cons_show("Autoconnect account set to: %s.", args[1]);
+            } else {
+                cons_show_error("Account '%s' does not exist.", args[1]);
+            }
+        }
     } else {
         cons_bad_cmd_usage(command);
     }
-    return true;
+    return TRUE;
 }
 
 gboolean