degesch: print out some basic help

This commit is contained in:
Přemysl Eric Janouch 2015-04-18 17:19:56 +02:00
parent e65b38bff9
commit 5dbd6eaa7e
1 changed files with 47 additions and 27 deletions

View File

@ -1814,48 +1814,68 @@ handle_command_quote (struct app_context *ctx, char *arguments)
static struct command_handler static struct command_handler
{ {
char *name; const char *name;
void (*handler) (struct app_context *ctx, char *arguments); void (*handler) (struct app_context *ctx, char *arguments);
// TODO: probably also a usage string const char *description;
const char *usage;
} }
g_command_handlers[] = g_command_handlers[] =
{ {
{ "help", handle_command_help }, { "help", handle_command_help, "Show help",
{ "quit", handle_command_quit }, "[command]" },
{ "buffer", handle_command_buffer }, { "quit", handle_command_quit, "Quit the program",
"[message]" },
{ "buffer", handle_command_buffer, "Manage buffers",
"list | clear | move | { close [<number> | <name>] } | <number>" },
#if 0 #if 0
{ "msg", NULL }, { "msg", NULL, "", "" },
{ "query", NULL }, { "query", NULL, "", "" },
{ "notice", NULL }, { "notice", NULL, "", "" },
{ "ctcp", NULL }, { "ctcp", NULL, "", "" },
{ "me", NULL }, { "me", NULL, "", "" },
{ "join", NULL }, { "join", NULL, "", "" },
{ "part", NULL }, { "part", NULL, "", "" },
{ "cycle", NULL }, { "cycle", NULL, "", "" },
{ "mode", NULL }, { "mode", NULL, "", "" },
{ "topic", NULL }, { "topic", NULL, "", "" },
{ "kick", NULL }, { "kick", NULL, "", "" },
{ "kickban", NULL }, { "kickban", NULL, "", "" },
{ "ban", NULL }, { "ban", NULL, "", "" },
{ "invite", NULL }, { "invite", NULL, "", "" },
{ "list", NULL }, { "list", NULL, "", "" },
{ "names", NULL }, { "names", NULL, "", "" },
{ "who", NULL }, { "who", NULL, "", "" },
{ "whois", NULL }, { "whois", NULL, "", "" },
{ "motd", NULL }, { "motd", NULL, "", "" },
{ "away", NULL }, { "away", NULL, "", "" },
#endif #endif
{ "quote", handle_command_quote }, { "quote", handle_command_quote, "Send a raw command to the server",
"command" },
}; };
static void static void
handle_command_help (struct app_context *ctx, char *arguments) 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 static int