void mu_config_show_help (MuConfigCmd cmd) { GOptionContext *ctx; GOptionGroup *group; char *cleanhelp; g_return_if_fail (mu_config_cmd_is_valid(cmd)); ctx = g_option_context_new (""); g_option_context_set_main_group (ctx, config_options_group_mu()); group = get_option_group (cmd); if (group) g_option_context_add_group (ctx, group); g_option_context_set_description (ctx, get_help_string (cmd, TRUE)); cleanhelp = massage_help (g_option_context_get_help (ctx, TRUE, group)); g_print ("usage:\n\t%s\n%s", get_help_string (cmd, FALSE), cleanhelp); g_free (cleanhelp); }
static gboolean init_cmd_help (GError **err) { MuConfigCmd cmd; GOptionContext *ctx; GOptionGroup *group; char *cleanhelp; if (!MU_CONFIG.params || !MU_CONFIG.params[0] || !MU_CONFIG.params[1] || MU_CONFIG.params[2]) goto errexit; cmd = cmd_from_string (MU_CONFIG.params[1]); if (cmd == MU_CONFIG_CMD_UNKNOWN) goto errexit; ctx = g_option_context_new (""); g_option_context_set_main_group (ctx, config_options_group_mu()); group = get_option_group (cmd); if (group) g_option_context_add_group (ctx, group); g_option_context_set_description (ctx, cmd_help (cmd, TRUE)); cleanhelp = massage_help (g_option_context_get_help (ctx, TRUE, group)); g_print ("Usage:\n\t%s\n%s", cmd_help (cmd, FALSE), cleanhelp); g_free (cleanhelp); return TRUE; errexit: mu_util_g_set_error (err, MU_ERROR_IN_PARAMETERS, "usage: mu help <command>"); return FALSE; }