diff options
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 82 |
1 files changed, 51 insertions, 31 deletions
@@ -1814,48 +1814,68 @@ handle_command_quote (struct app_context *ctx, char *arguments) static struct command_handler { - char *name; + const char *name; void (*handler) (struct app_context *ctx, char *arguments); - // TODO: probably also a usage string + const char *description; + const char *usage; } g_command_handlers[] = { - { "help", handle_command_help }, - { "quit", handle_command_quit }, - { "buffer", handle_command_buffer }, + { "help", handle_command_help, "Show help", + "[command]" }, + { "quit", handle_command_quit, "Quit the program", + "[message]" }, + { "buffer", handle_command_buffer, "Manage buffers", + "list | clear | move | { close [<number> | <name>] } | <number>" }, #if 0 - { "msg", NULL }, - { "query", NULL }, - { "notice", NULL }, - { "ctcp", NULL }, - { "me", NULL }, - - { "join", NULL }, - { "part", NULL }, - { "cycle", NULL }, - - { "mode", NULL }, - { "topic", NULL }, - { "kick", NULL }, - { "kickban", NULL }, - { "ban", NULL }, - { "invite", NULL }, - - { "list", NULL }, - { "names", NULL }, - { "who", NULL }, - { "whois", NULL }, - - { "motd", NULL }, - { "away", NULL }, + { "msg", NULL, "", "" }, + { "query", NULL, "", "" }, + { "notice", NULL, "", "" }, + { "ctcp", NULL, "", "" }, + { "me", NULL, "", "" }, + + { "join", NULL, "", "" }, + { "part", NULL, "", "" }, + { "cycle", NULL, "", "" }, + + { "mode", NULL, "", "" }, + { "topic", NULL, "", "" }, + { "kick", NULL, "", "" }, + { "kickban", NULL, "", "" }, + { "ban", NULL, "", "" }, + { "invite", NULL, "", "" }, + + { "list", NULL, "", "" }, + { "names", NULL, "", "" }, + { "who", NULL, "", "" }, + { "whois", NULL, "", "" }, + + { "motd", NULL, "", "" }, + { "away", NULL, "", "" }, #endif - { "quote", handle_command_quote }, + { "quote", handle_command_quote, "Send a raw command to the server", + "command" }, }; static void handle_command_help (struct app_context *ctx, char *arguments) { - // TODO: show a list of all user commands + if (*arguments) + { + char *command = cut_word (&arguments); + // TODO: search for the command and show specific help + return; + } + + buffer_send_status (ctx, ctx->global_buffer, "Commands:"); + for (size_t i = 0; i < N_ELEMENTS (g_command_handlers); i++) + { + struct command_handler *iter = &g_command_handlers[i]; + buffer_send_status (ctx, ctx->global_buffer, + " %s: %s", iter->name, iter->description); + buffer_send_status (ctx, ctx->global_buffer, + " Arguments: %s", iter->usage); + } } static int |