diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-09 23:07:48 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-09 23:07:48 +0200 |
commit | 789db85915baf79c2ade61aecede8c365103f363 (patch) | |
tree | 320d8c8921aed56cad612590b0a05cdd3345e02b /degesch.c | |
parent | ad4ebc21017e39bb8bc8a08a8985cc735914e9d4 (diff) | |
download | xK-789db85915baf79c2ade61aecede8c365103f363.tar.gz xK-789db85915baf79c2ade61aecede8c365103f363.tar.xz xK-789db85915baf79c2ade61aecede8c365103f363.zip |
degesch: add command placeholders
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 131 |
1 files changed, 76 insertions, 55 deletions
@@ -4821,68 +4821,85 @@ handle_command_quote (struct app_context *ctx, char *arguments) static bool handle_command_help (struct app_context *, char *); +#define NOT_IMPLEMENTED(name) { #name, "(Not implemented)", NULL, NULL }, + static struct command_handler { const char *name; - bool (*handler) (struct app_context *ctx, char *arguments); const char *description; const char *usage; + bool (*handler) (struct app_context *ctx, char *arguments); } g_command_handlers[] = { - { "help", handle_command_help, "Show help", - "[<command> | <option>]" }, - { "quit", handle_command_quit, "Quit the program", - "[<message>]" }, - { "buffer", handle_command_buffer, "Manage buffers", - "list | clear | move | { close [<number> | <name>] } | <number>" }, - { "set", handle_command_set, "Manage configuration", - "[<option>]" }, - { "save", handle_command_save, "Save configuration", - "" }, - - { "msg", handle_command_msg, "Send message to a nick or channel", - "<target> <message>" }, - { "query", handle_command_query, "Send a private message to a nick", - "<nick> <message>" }, - { "notice", handle_command_notice, "Send notice to a nick or channel", - "<target> <message>" }, - { "ctcp", handle_command_ctcp, "Send a CTCP query", - "<target> <tag>" }, - { "me", handle_command_me, "Send a CTCP action", - "<message>" }, - - { "join", handle_command_join, "Join channels", - "[<channel>[,<channel>...]]" }, - { "part", handle_command_part, "Leave channels", - "[<channel>[,<channel>...]]" }, -#if 0 - { "cycle", NULL, "", "" }, - - { "mode", NULL, "", "" }, - { "topic", NULL, "", "" }, - { "kick", NULL, "", "" }, - { "kickban", NULL, "", "" }, - { "ban", NULL, "", "" }, - { "invite", NULL, "", "" }, -#endif - - { "connect", handle_command_connect, "Connect to the server", - "" }, - { "list", handle_command_list, "List channels and their topic", - "[<channel>[,<channel>...]] [server]" }, -#if 0 - { "names", NULL, "", "" }, - { "who", NULL, "", "" }, - { "whois", NULL, "", "" }, - - { "motd", NULL, "", "" }, - { "away", NULL, "", "" }, -#endif - { "nick", handle_command_nick, "Change current nick", - "<nickname>" }, - { "quote", handle_command_quote, "Send a raw command to the server", - "<command>" }, + { "help", "Show help", + "[<command> | <option>]", + handle_command_help }, + { "quit", "Quit the program", + "[<message>]", + handle_command_quit }, + { "buffer", "Manage buffers", + "list | clear | move | { close [<number> | <name>] } | <number>", + handle_command_buffer }, + { "set", "Manage configuration", + "[<option>]", + handle_command_set }, + { "save", "Save configuration", + NULL, + handle_command_save }, + + { "msg", "Send message to a nick or channel", + "<target> <message>", + handle_command_msg }, + { "query", "Send a private message to a nick", + "<nick> <message>", + handle_command_query }, + { "notice", "Send notice to a nick or channel", + "<target> <message>", + handle_command_notice }, + { "ctcp", "Send a CTCP query", + "<target> <tag>", + handle_command_ctcp }, + { "me", "Send a CTCP action", + "<message>", + handle_command_me }, + + { "join", "Join channels", + "[<channel>[,<channel>...]]", + handle_command_join }, + { "part", "Leave channels", + "[<channel>[,<channel>...]]", + handle_command_part }, + NOT_IMPLEMENTED (cycle) + + NOT_IMPLEMENTED (mode) + NOT_IMPLEMENTED (topic) + NOT_IMPLEMENTED (kick) + NOT_IMPLEMENTED (kickban) + NOT_IMPLEMENTED (ban) + NOT_IMPLEMENTED (invite) + + { "connect", "Connect to the server", + NULL, + handle_command_connect }, + { "disconnect", "Disconnect from the server", + NULL, + NULL }, + { "list", "List channels and their topic", + "[<channel>[,<channel>...]] [server]", + handle_command_list }, + NOT_IMPLEMENTED (names) + NOT_IMPLEMENTED (who) + NOT_IMPLEMENTED (whois) + + NOT_IMPLEMENTED (motd) + NOT_IMPLEMENTED (away) + { "nick", "Change current nick", + "<nickname>", + handle_command_nick }, + { "quote", "Send a raw command to the server", + "<command>", + handle_command_quote }, }; static bool @@ -4947,7 +4964,7 @@ handle_command_help (struct app_context *ctx, char *arguments) buffer_send_status (ctx, ctx->global_buffer, "%s: %s", handler->name, handler->description); buffer_send_status (ctx, ctx->global_buffer, " Arguments: %s", - handler->usage); + handler->usage ? handler->usage : "(none)"); return true; } @@ -5011,6 +5028,10 @@ process_user_command (struct app_context *ctx, char *command) if (!handler) buffer_send_error (ctx, ctx->global_buffer, "%s: %s", "No such command", name); + // TODO: remove once everything is implemented + else if (!handler->handler) + buffer_send_error (ctx, ctx->global_buffer, + "%s: %s", "Not implemented", name); else if (!handler->handler (ctx, command)) buffer_send_error (ctx, ctx->global_buffer, "%s: /%s %s", "Usage", handler->name, handler->usage); |