about summary refs log tree commit diff stats
path: root/src/command/commands.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-09-14 01:53:52 +0100
committerJames Booth <boothj5@gmail.com>2014-09-14 01:53:52 +0100
commit7a126845236d711412e4375bea747b61dd8069b1 (patch)
treec3f496256b15b1c9c68cd41022093aae6e46cdc0 /src/command/commands.c
parent68b839a50870184d13970401035b462b6fb7087f (diff)
downloadprofani-tty-7a126845236d711412e4375bea747b61dd8069b1.tar.gz
Added /room remove command, reformetted form output
Diffstat (limited to 'src/command/commands.c')
-rw-r--r--src/command/commands.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 57687ea9..fc3e5298 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -2021,7 +2021,29 @@ cmd_room(gchar **args, struct cmd_help_t help)
             if (!form_tag_exists(current->form, tag)) {
                 ui_current_print_line("Form does not contain a field with tag %s", tag);
             } else {
-                ui_current_print_line("Remove Tag: %s, Value: %s", tag, value);
+                form_field_type_t field_type = form_get_field_type(current->form, tag);
+                gboolean valid = FALSE;
+                switch (field_type) {
+                case FIELD_LIST_MULTI:
+                    valid = form_field_contains_option(current->form, tag, value);
+                    if (valid == TRUE) {
+                        form_remove_value(current->form, tag, value);
+                        ui_current_print_line("Removed %s from %s", value, tag);
+                    } else {
+                        ui_current_print_line("Value %s not a valid option for field: %s", value, tag);
+                    }
+                    break;
+                case FIELD_TEXT_MULTI:
+                    ui_current_print_line("TODO");
+                    break;
+                case FIELD_JID_MULTI:
+                    form_remove_value(current->form, tag, value);
+                    ui_current_print_line("Removed %s from %s", value, tag);
+                    break;
+                default:
+                    ui_current_print_line("Remove command not valid for field: %s", tag);
+                    break;
+                }
             }
         }