diff options
author | James Booth <boothj5@gmail.com> | 2014-01-23 22:29:53 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2014-01-23 22:29:53 +0000 |
commit | 8dbe300d72e3bdaba672b4a7027ab0f2fb431862 (patch) | |
tree | 521260cc8995af389f26d96ecf634c6fcaae98ba /src/command/commands.c | |
parent | 8ba2d2694756da38b680befff88fdaea1b5ef8bf (diff) | |
download | profani-tty-8dbe300d72e3bdaba672b4a7027ab0f2fb431862.tar.gz |
Added /alias command, writing aliases to [alias] group in profrc
Diffstat (limited to 'src/command/commands.c')
-rw-r--r-- | src/command/commands.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/command/commands.c b/src/command/commands.c index 712d39d8..c4390966 100644 --- a/src/command/commands.c +++ b/src/command/commands.c @@ -1821,8 +1821,47 @@ cmd_nick(gchar **args, struct cmd_help_t help) gboolean cmd_alias(gchar **args, struct cmd_help_t help) { - cons_show("Alias command TODO"); - return TRUE; + char *subcmd = args[0]; + + if (strcmp(subcmd, "add") == 0) { + char *alias = args[1]; + if (alias == NULL) { + cons_show("Usage: %s", help.usage); + return TRUE; + } else { + char *value = args[2]; + if (value == NULL) { + cons_show("Usage: %s", help.usage); + return TRUE; + } else { + prefs_add_alias(alias, value); + cons_show("Command alias added /%s -> %s", alias, value); + return TRUE; + } + } + } else if (strcmp(subcmd, "remove") == 0) { + char *alias = args[1]; + if (alias == NULL) { + cons_show("Usage: %s", help.usage); + return TRUE; + } else { + gboolean removed = prefs_remove_alias(alias); + if (!removed) { + cons_show("No such command alias /%s", alias); + } else { + cons_show("Command alias removed -> /%s", alias); + } + return TRUE; + } + } else if (strcmp(subcmd, "list") == 0) { + GList *aliases = prefs_get_aliases(); + cons_show_aliases(aliases); + prefs_free_aliases(aliases); + return TRUE; + } else { + cons_show("Usage: %s", help.usage); + return TRUE; + } } gboolean |