From 5dbd6eaa7ec9a05162bad89d18604ac7e077a6ee Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 18 Apr 2015 17:19:56 +0200
Subject: degesch: print out some basic help
---
degesch.c | 82 +++++++++++++++++++++++++++++++++++++++------------------------
1 file 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 [ | ] } | " },
#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
--
cgit v1.2.3-70-g09d2