diff options
| author | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2020-05-05 21:24:37 +0300 |
|---|---|---|
| committer | Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> | 2020-05-05 21:24:37 +0300 |
| commit | f3b70bf0499a774fd351dbb90fa8588231f0dbc6 (patch) | |
| tree | ca5c8ea598e989d88f5e7651d78a9210fee349e4 | |
| parent | 7ddcc2159fbca875fc9b387f319dafc3700c2d4f (diff) | |
mu: support --eval for server testing
Add a hidden command-line argument, just for testing.
| -rw-r--r-- | mu/mu-cmd-server.cc | 6 | ||||
| -rw-r--r-- | mu/mu-config.c | 3 | ||||
| -rw-r--r-- | mu/mu-config.h | 3 |
3 files changed, 11 insertions, 1 deletions
diff --git a/mu/mu-cmd-server.cc b/mu/mu-cmd-server.cc index 0b05417..d6261d6 100644 --- a/mu/mu-cmd-server.cc +++ b/mu/mu-cmd-server.cc @@ -1375,6 +1375,12 @@ mu_cmd_server (MuConfig *opts, GError **err) try Context context{opts}; 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"}; Readline readline(histpath, 50); diff --git a/mu/mu-config.c b/mu/mu-config.c index af98a37..89538cd 100644 --- a/mu/mu-config.c +++ b/mu/mu-config.c @@ -453,6 +453,8 @@ config_options_group_server (void) GOptionEntry entries[] = { {"commands", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.commands, "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} }; @@ -766,6 +768,7 @@ mu_config_uninit (MuConfig *opts) g_free (opts->targetdir); g_free (opts->parts); g_free (opts->script); + g_free (opts->eval); g_strfreev (opts->params); diff --git a/mu/mu-config.h b/mu/mu-config.h index 1d1bec0..43418ae 100644 --- a/mu/mu-config.h +++ b/mu/mu-config.h @@ -184,8 +184,9 @@ struct _MuConfig { /* for server */ gboolean commands; /* dump documentations for server * commands */ + gchar *eval; /* command to evaluate */ - /* options for mu-script */ + /* options for mu-script */ gchar *script; /* script to run */ const char **script_params; /* parameters for scripts */ }; |
