mirror of https://github.com/djcb/mu.git
mu: support --eval for server testing
Add a hidden command-line argument, just for testing.
This commit is contained in:
parent
7ddcc2159f
commit
f3b70bf049
|
@ -1375,6 +1375,12 @@ mu_cmd_server (MuConfig *opts, GError **err) try
|
||||||
Context context{opts};
|
Context context{opts};
|
||||||
context.command_map = make_command_map (context);
|
context.command_map = make_command_map (context);
|
||||||
|
|
||||||
|
if (opts->eval) { // evaluate command-line command & exit
|
||||||
|
auto call{Sexp::parse(opts->eval)};
|
||||||
|
invoke(context.command_map, call);
|
||||||
|
return MU_OK;
|
||||||
|
}
|
||||||
|
|
||||||
const auto histpath{std::string{mu_runtime_path(MU_RUNTIME_PATH_CACHE)} + "/history"};
|
const auto histpath{std::string{mu_runtime_path(MU_RUNTIME_PATH_CACHE)} + "/history"};
|
||||||
Readline readline(histpath, 50);
|
Readline readline(histpath, 50);
|
||||||
|
|
||||||
|
|
|
@ -453,6 +453,8 @@ config_options_group_server (void)
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"commands", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.commands,
|
{"commands", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.commands,
|
||||||
"list the available command and their parameters, then exit", NULL},
|
"list the available command and their parameters, then exit", NULL},
|
||||||
|
{"eval", 'e', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING,
|
||||||
|
&MU_CONFIG.eval, "expression to evaluate", "<expr>"},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -766,6 +768,7 @@ mu_config_uninit (MuConfig *opts)
|
||||||
g_free (opts->targetdir);
|
g_free (opts->targetdir);
|
||||||
g_free (opts->parts);
|
g_free (opts->parts);
|
||||||
g_free (opts->script);
|
g_free (opts->script);
|
||||||
|
g_free (opts->eval);
|
||||||
|
|
||||||
g_strfreev (opts->params);
|
g_strfreev (opts->params);
|
||||||
|
|
||||||
|
|
|
@ -184,8 +184,9 @@ struct _MuConfig {
|
||||||
/* for server */
|
/* for server */
|
||||||
gboolean commands; /* dump documentations for server
|
gboolean commands; /* dump documentations for server
|
||||||
* commands */
|
* commands */
|
||||||
|
gchar *eval; /* command to evaluate */
|
||||||
|
|
||||||
/* options for mu-script */
|
/* options for mu-script */
|
||||||
gchar *script; /* script to run */
|
gchar *script; /* script to run */
|
||||||
const char **script_params; /* parameters for scripts */
|
const char **script_params; /* parameters for scripts */
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue