about summary refs log tree commit diff stats
path: root/src/command
diff options
context:
space:
mode:
authorWill Song <incertia9474@gmail.com>2014-11-27 20:26:10 -0600
committerWill Song <incertia9474@gmail.com>2014-11-27 20:26:10 -0600
commit6a3285795a52ae0d177d079e9ee23bb092ef76d7 (patch)
tree764c98995b76841377eaaa66bd1b914ba3754a3d /src/command
parent3b13c00df4c99239180d42ea347413061342cf5a (diff)
downloadprofani-tty-6a3285795a52ae0d177d079e9ee23bb092ef76d7.tar.gz
removing the account connected to the default account removes the default account as well
Diffstat (limited to 'src/command')
-rw-r--r--src/command/commands.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index e217e7e8..c294a16b 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -206,13 +206,19 @@ cmd_account(gchar **args, struct cmd_help_t help)
         if(!account_name) {
             cons_show("Usage: %s", help.usage);
         } else {
+            char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT);
             if(accounts_remove(account_name)){
                 cons_show("Account %s removed.", account_name);
+                if(def && strcmp(def, account_name) == 0){
+                    prefs_set_string(PREF_DEFAULT_ACCOUNT, NULL);
+                    cons_show("Default account removed because the corresponding account was removed.");
+                }
             } else {
                 cons_show("Failed to remove account %s.", account_name);
                 cons_show("Either the account does not exist, or an unknown error occurred.");
             }
             cons_show("");
+            g_free(def);
         }
     } else if (strcmp(command, "enable") == 0) {
         char *account_name = args[1];