diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-03 05:58:56 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2015-05-03 05:58:56 +0200 |
commit | f308b3fb5dbb8eee5cd6894ab75d0d265572ada9 (patch) | |
tree | 9de9536f11a28074afcfc4b1a1e9a964c136144d | |
parent | bef6b42d9e86389a841622d8b46498572b7e837e (diff) | |
download | xK-f308b3fb5dbb8eee5cd6894ab75d0d265572ada9.tar.gz xK-f308b3fb5dbb8eee5cd6894ab75d0d265572ada9.tar.xz xK-f308b3fb5dbb8eee5cd6894ab75d0d265572ada9.zip |
degesch: show help for program options
-rw-r--r-- | degesch.c | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -3886,9 +3886,9 @@ static struct command_handler g_command_handlers[] = { { "help", handle_command_help, "Show help", - "[command]" }, + "[<command> | <option>]" }, { "quit", handle_command_quit, "Quit the program", - "[message]" }, + "[<message>]" }, { "buffer", handle_command_buffer, "Manage buffers", "list | clear | move | { close [<number> | <name>] } | <number>" }, @@ -3964,8 +3964,33 @@ handle_command_help (struct app_context *ctx, char *arguments) return true; } } + + struct config_item_ *item = + config_item_get (ctx->config.root, command, NULL); + if (item) + { + struct config_schema *schema = item->schema; + buffer_send_status (ctx, ctx->global_buffer, "%s", ""); + buffer_send_status (ctx, ctx->global_buffer, + "Option \"%s\":", command); + buffer_send_status (ctx, ctx->global_buffer, + " Description: %s", schema->comment); + buffer_send_status (ctx, ctx->global_buffer, + " Type: %s", config_item_type_name (schema->type)); + buffer_send_status (ctx, ctx->global_buffer, + " Default: %s", schema->default_ ? schema->default_ : "null"); + + struct str tmp; + str_init (&tmp); + config_item_write (item, false, &tmp); + buffer_send_status (ctx, ctx->global_buffer, + " Current value: %s", tmp.str); + str_free (&tmp); + return true; + } + buffer_send_error (ctx, ctx->global_buffer, - "%s: %s", "No such command", command); + "%s: %s", "No such command or option", command); return true; } |