degesch: add command placeholders

This commit is contained in:
Přemysl Eric Janouch 2015-05-09 23:07:48 +02:00
parent ad4ebc2101
commit 789db85915
1 changed files with 71 additions and 50 deletions

121
degesch.c
View File

@ -4821,68 +4821,85 @@ handle_command_quote (struct app_context *ctx, char *arguments)
static bool handle_command_help (struct app_context *, char *); static bool handle_command_help (struct app_context *, char *);
#define NOT_IMPLEMENTED(name) { #name, "(Not implemented)", NULL, NULL },
static struct command_handler static struct command_handler
{ {
const char *name; const char *name;
bool (*handler) (struct app_context *ctx, char *arguments);
const char *description; const char *description;
const char *usage; const char *usage;
bool (*handler) (struct app_context *ctx, char *arguments);
} }
g_command_handlers[] = g_command_handlers[] =
{ {
{ "help", handle_command_help, "Show help", { "help", "Show help",
"[<command> | <option>]" }, "[<command> | <option>]",
{ "quit", handle_command_quit, "Quit the program", handle_command_help },
"[<message>]" }, { "quit", "Quit the program",
{ "buffer", handle_command_buffer, "Manage buffers", "[<message>]",
"list | clear | move | { close [<number> | <name>] } | <number>" }, handle_command_quit },
{ "set", handle_command_set, "Manage configuration", { "buffer", "Manage buffers",
"[<option>]" }, "list | clear | move | { close [<number> | <name>] } | <number>",
{ "save", handle_command_save, "Save configuration", handle_command_buffer },
"" }, { "set", "Manage configuration",
"[<option>]",
handle_command_set },
{ "save", "Save configuration",
NULL,
handle_command_save },
{ "msg", handle_command_msg, "Send message to a nick or channel", { "msg", "Send message to a nick or channel",
"<target> <message>" }, "<target> <message>",
{ "query", handle_command_query, "Send a private message to a nick", handle_command_msg },
"<nick> <message>" }, { "query", "Send a private message to a nick",
{ "notice", handle_command_notice, "Send notice to a nick or channel", "<nick> <message>",
"<target> <message>" }, handle_command_query },
{ "ctcp", handle_command_ctcp, "Send a CTCP query", { "notice", "Send notice to a nick or channel",
"<target> <tag>" }, "<target> <message>",
{ "me", handle_command_me, "Send a CTCP action", handle_command_notice },
"<message>" }, { "ctcp", "Send a CTCP query",
"<target> <tag>",
handle_command_ctcp },
{ "me", "Send a CTCP action",
"<message>",
handle_command_me },
{ "join", handle_command_join, "Join channels", { "join", "Join channels",
"[<channel>[,<channel>...]]" }, "[<channel>[,<channel>...]]",
{ "part", handle_command_part, "Leave channels", handle_command_join },
"[<channel>[,<channel>...]]" }, { "part", "Leave channels",
#if 0 "[<channel>[,<channel>...]]",
{ "cycle", NULL, "", "" }, handle_command_part },
NOT_IMPLEMENTED (cycle)
{ "mode", NULL, "", "" }, NOT_IMPLEMENTED (mode)
{ "topic", NULL, "", "" }, NOT_IMPLEMENTED (topic)
{ "kick", NULL, "", "" }, NOT_IMPLEMENTED (kick)
{ "kickban", NULL, "", "" }, NOT_IMPLEMENTED (kickban)
{ "ban", NULL, "", "" }, NOT_IMPLEMENTED (ban)
{ "invite", NULL, "", "" }, NOT_IMPLEMENTED (invite)
#endif
{ "connect", handle_command_connect, "Connect to the server", { "connect", "Connect to the server",
"" }, NULL,
{ "list", handle_command_list, "List channels and their topic", handle_command_connect },
"[<channel>[,<channel>...]] [server]" }, { "disconnect", "Disconnect from the server",
#if 0 NULL,
{ "names", NULL, "", "" }, NULL },
{ "who", NULL, "", "" }, { "list", "List channels and their topic",
{ "whois", NULL, "", "" }, "[<channel>[,<channel>...]] [server]",
handle_command_list },
NOT_IMPLEMENTED (names)
NOT_IMPLEMENTED (who)
NOT_IMPLEMENTED (whois)
{ "motd", NULL, "", "" }, NOT_IMPLEMENTED (motd)
{ "away", NULL, "", "" }, NOT_IMPLEMENTED (away)
#endif { "nick", "Change current nick",
{ "nick", handle_command_nick, "Change current nick", "<nickname>",
"<nickname>" }, handle_command_nick },
{ "quote", handle_command_quote, "Send a raw command to the server", { "quote", "Send a raw command to the server",
"<command>" }, "<command>",
handle_command_quote },
}; };
static bool static bool
@ -4947,7 +4964,7 @@ handle_command_help (struct app_context *ctx, char *arguments)
buffer_send_status (ctx, ctx->global_buffer, "%s: %s", buffer_send_status (ctx, ctx->global_buffer, "%s: %s",
handler->name, handler->description); handler->name, handler->description);
buffer_send_status (ctx, ctx->global_buffer, " Arguments: %s", buffer_send_status (ctx, ctx->global_buffer, " Arguments: %s",
handler->usage); handler->usage ? handler->usage : "(none)");
return true; return true;
} }
@ -5011,6 +5028,10 @@ process_user_command (struct app_context *ctx, char *command)
if (!handler) if (!handler)
buffer_send_error (ctx, ctx->global_buffer, buffer_send_error (ctx, ctx->global_buffer,
"%s: %s", "No such command", name); "%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)) else if (!handler->handler (ctx, command))
buffer_send_error (ctx, ctx->global_buffer, buffer_send_error (ctx, ctx->global_buffer,
"%s: /%s %s", "Usage", handler->name, handler->usage); "%s: /%s %s", "Usage", handler->name, handler->usage);