aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-04-18 17:19:56 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-04-18 17:19:56 +0200
commit5dbd6eaa7ec9a05162bad89d18604ac7e077a6ee (patch)
tree9a9993995a05e6a12cb034ded0845321636a5af7
parente65b38bff9100908f8be8a8391ca025c1120a618 (diff)
downloadxK-5dbd6eaa7ec9a05162bad89d18604ac7e077a6ee.tar.gz
xK-5dbd6eaa7ec9a05162bad89d18604ac7e077a6ee.tar.xz
xK-5dbd6eaa7ec9a05162bad89d18604ac7e077a6ee.zip
degesch: print out some basic help
-rw-r--r--degesch.c82
1 files changed, 51 insertions, 31 deletions
diff --git a/degesch.c b/degesch.c
index c5e94b9..3fe9b38 100644
--- a/degesch.c
+++ b/degesch.c
@@ -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