Ejemplo n.º 1
0
static gboolean
parse_cmd (int *argcp, char ***argvp, GError **err)
{
	MU_CONFIG.cmd	 = MU_CONFIG_CMD_NONE;
	MU_CONFIG.cmdstr = NULL;

	if (*argcp < 2) /* no command found at all */
		return TRUE;
	else if ((**argvp)[1] == '-')
		/* if the first param starts with '-', there is no
		 * command, just some option (like --version, --help
		 * etc.)*/
		return TRUE;

	MU_CONFIG.cmdstr = (*argvp)[1];
	MU_CONFIG.cmd    = cmd_from_string (MU_CONFIG.cmdstr);

#ifndef BUILD_GUILE
	if (MU_CONFIG.cmd == MU_CONFIG_CMD_SCRIPT) {
		mu_util_g_set_error (err, MU_ERROR_IN_PARAMETERS,
				     "command 'script' not supported");
		return FALSE;
	}
#endif /*!BUILD_GUILE*/

	return TRUE;
}
Ejemplo n.º 2
0
static gboolean
parse_cmd (int *argcp, char ***argvp)
{
	MU_CONFIG.cmd	 = MU_CONFIG_CMD_NONE;
	MU_CONFIG.cmdstr = NULL;

	if (*argcp < 2) /* no command found at all */
		return TRUE;
	else if ((**argvp)[1] == '-')
		/* if the first param starts with '-', there is no
		 * command, just some option (like --version, --help
		 * etc.)*/
		return TRUE;

	MU_CONFIG.cmdstr = (*argvp)[1];
	MU_CONFIG.cmd    = cmd_from_string (MU_CONFIG.cmdstr);

	return TRUE;
}
Ejemplo n.º 3
0
static gboolean
cmd_help (void)
{
	MuConfigCmd cmd;

	if (!MU_CONFIG.params)
		cmd = MU_CONFIG_CMD_UNKNOWN;
	else
		cmd = cmd_from_string (MU_CONFIG.params[1]);

	if (cmd == MU_CONFIG_CMD_UNKNOWN) {
		mu_config_show_help (MU_CONFIG_CMD_HELP);
		return TRUE;
	}

	mu_config_show_help (cmd);

	return TRUE;
}
Ejemplo n.º 4
0
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;
}