aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
authorWill Song <incertia9474@gmail.com>2014-11-27 11:42:23 -0600
committerWill Song <incertia9474@gmail.com>2014-11-27 11:42:23 -0600
commitde9e621bb776b91aecfca02973fbfcbe16b38162 (patch)
tree6f02adff5cce85a428bb4875af15bc1343a13d67 /src/command
parent94bd9dbdfe7e7188e20bddf68565277630197822 (diff)
downloadprofani-tty-de9e621bb776b91aecfca02973fbfcbe16b38162.tar.gz
add default account property and commands associated with them
Diffstat (limited to 'src/command')
-rw-r--r--src/command/commands.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index fc95f521..ba6b44fc 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -243,6 +243,37 @@ cmd_account(gchar **args, struct cmd_help_t help)
cons_show("");
}
}
+ } else if (strcmp(command, "default") == 0) {
+ if(g_strv_length(args) == 1){
+ char *def = prefs_get_string(PREF_DEFAULT_ACCOUNT);
+
+ if(def){
+ cons_show("The default account is %s.", def);
+ free(def);
+ } else {
+ cons_show("No default account.");
+ }
+ } else if(g_strv_length(args) == 2){
+ if(strcmp(args[1], "off") == 0){
+ prefs_set_string(PREF_DEFAULT_ACCOUNT, NULL);
+ cons_show("Removed default account.");
+ } else {
+ cons_show("Usage: %s", help.usage);
+ }
+ } else if(g_strv_length(args) == 3) {
+ if(strcmp(args[1], "set") == 0){
+ if(accounts_get_account(args[2])){
+ prefs_set_string(PREF_DEFAULT_ACCOUNT, args[2]);
+ cons_show("Default account set to %s.", args[2]);
+ } else {
+ cons_show("Account %s does not exist.", args[2]);
+ }
+ } else {
+ cons_show("Usage: %s", help.usage);
+ }
+ } else {
+ cons_show("Usage: %s", help.usage);
+ }
} else if (strcmp(command, "set") == 0) {
if (g_strv_length(args) != 4) {
cons_show("Usage: %s", help.usage);