Пример #1
0
MuError
mu_cmd_execute (MuConfig *opts, GError **err)
{
	g_return_val_if_fail (opts, MU_ERROR_INTERNAL);

	if (opts->version) {
		show_version ();
		return MU_OK;
	}

	if (!check_params(opts, err))
		return MU_G_ERROR_CODE(err);

	switch (opts->cmd) {
		/* already handled in mu-config.c */
	case MU_CONFIG_CMD_HELP: return MU_OK;

	case MU_CONFIG_CMD_CFIND:   return mu_cmd_cfind (opts, err);
	case MU_CONFIG_CMD_MKDIR:   return mu_cmd_mkdir (opts, err);
	case MU_CONFIG_CMD_VIEW:    return mu_cmd_view (opts, err);
	case MU_CONFIG_CMD_VERIFY:  return mu_cmd_verify (opts, err);
	case MU_CONFIG_CMD_EXTRACT: return mu_cmd_extract (opts, err);

	case MU_CONFIG_CMD_FIND:
		return with_store (mu_cmd_find, opts, TRUE, err);
	case MU_CONFIG_CMD_INDEX:
		return with_store (mu_cmd_index, opts, FALSE, err);
	case MU_CONFIG_CMD_ADD:
		return with_store (mu_cmd_add, opts, FALSE, err);
	case MU_CONFIG_CMD_REMOVE:
		return with_store (mu_cmd_remove, opts, FALSE, err);
	case MU_CONFIG_CMD_SERVER:
		return with_store (mu_cmd_server, opts, FALSE, err);
	default:
		show_usage ();
		g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_IN_PARAMETERS,
			     "unknown command '%s'", opts->cmdstr);
		return MU_ERROR_IN_PARAMETERS;
	}
}
Пример #2
0
MuError
mu_cmd_execute (MuConfig *opts, GError **err)
{
	MuError merr;

	g_return_val_if_fail (opts, MU_ERROR_INTERNAL);

	if (!check_params(opts, err))
		return MU_G_ERROR_CODE(err);

	set_log_options (opts);

	switch (opts->cmd) {
		/* already handled in mu-config.c */
	case MU_CONFIG_CMD_HELP: return MU_OK;

	case MU_CONFIG_CMD_CFIND:   merr = mu_cmd_cfind   (opts, err); break;
	case MU_CONFIG_CMD_MKDIR:   merr = mu_cmd_mkdir   (opts, err); break;
	case MU_CONFIG_CMD_SCRIPT:  merr = mu_cmd_script  (opts, err); break;
	case MU_CONFIG_CMD_VIEW:    merr = mu_cmd_view    (opts, err); break;
	case MU_CONFIG_CMD_VERIFY:  merr = mu_cmd_verify  (opts, err); break;
	case MU_CONFIG_CMD_EXTRACT: merr = mu_cmd_extract (opts, err); break;

	case MU_CONFIG_CMD_FIND:
		merr = with_store (mu_cmd_find, opts, TRUE, err);      break;
	case MU_CONFIG_CMD_INDEX:
		merr = with_store (mu_cmd_index, opts, FALSE, err);    break;
	case MU_CONFIG_CMD_ADD:
		merr = with_store (mu_cmd_add, opts, FALSE, err);      break;
	case MU_CONFIG_CMD_REMOVE:
		merr = with_store (mu_cmd_remove, opts, FALSE, err);   break;
	case MU_CONFIG_CMD_SERVER:
		merr = with_store (mu_cmd_server, opts, FALSE, err);   break;
	default:
		merr = MU_ERROR_IN_PARAMETERS; break;
	}

	return merr;
}