mu: add 'scm' command
Add the "scm" command, the way to get a Guile/Scheme shell. This is experimental but will replace the current guile support in guile/ at some point.
This commit is contained in:
@ -306,6 +306,15 @@ if not get_option('guile').disabled() and guile_dep.found()
|
|||||||
subdir('guile')
|
subdir('guile')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# this must happen _after_ subdir('lib')
|
||||||
|
if not get_option('scm').disabled() and guile_dep.found()
|
||||||
|
config_h_data.set('BUILD_SCM', 1)
|
||||||
|
subdir('scm')
|
||||||
|
else
|
||||||
|
# dummy-dep.
|
||||||
|
mu_scm_dep = declare_dependency('', required:false)
|
||||||
|
endif
|
||||||
|
|
||||||
subdir('mu')
|
subdir('mu')
|
||||||
|
|
||||||
# emacs -- needed for mu4e compilation
|
# emacs -- needed for mu4e compilation
|
||||||
|
|||||||
@ -35,7 +35,7 @@ option('lispdir',
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# guile
|
# guile & scm
|
||||||
#
|
#
|
||||||
|
|
||||||
option('guile',
|
option('guile',
|
||||||
@ -48,6 +48,11 @@ option('guile-extension-dir',
|
|||||||
type: 'string',
|
type: 'string',
|
||||||
description: 'custom install path for the guile extension module')
|
description: 'custom install path for the guile extension module')
|
||||||
|
|
||||||
|
option('scm',
|
||||||
|
type : 'feature',
|
||||||
|
value: 'auto',
|
||||||
|
description: 'build the guile scripting support (requires guile-3.x)')
|
||||||
|
|
||||||
#
|
#
|
||||||
# misc
|
# misc
|
||||||
#
|
#
|
||||||
|
|||||||
@ -288,8 +288,20 @@ topic_mu(const Options& opts)
|
|||||||
"yes"
|
"yes"
|
||||||
#else
|
#else
|
||||||
"no"
|
"no"
|
||||||
#endif
|
#endif /*BUILD_GUILE*/
|
||||||
, "GNU Guile 3.x scripting support?"});
|
, "GNU Guile 3.x support (old)?"});
|
||||||
|
|
||||||
|
info.add_row({"scm-support",
|
||||||
|
#if BUILD_SCM
|
||||||
|
"yes"
|
||||||
|
#else
|
||||||
|
"no"
|
||||||
|
#endif /*BUILD_SCM*/
|
||||||
|
, "GNU Guile 3.x support (new)?"});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
info.add_row({"readline-support",
|
info.add_row({"readline-support",
|
||||||
#if HAVE_LIBREADLINE
|
#if HAVE_LIBREADLINE
|
||||||
"yes"
|
"yes"
|
||||||
|
|||||||
19
mu/mu-cmd.cc
19
mu/mu-cmd.cc
@ -35,6 +35,10 @@
|
|||||||
#include "message/mu-message.hh"
|
#include "message/mu-message.hh"
|
||||||
#include "message/mu-mime-object.hh"
|
#include "message/mu-mime-object.hh"
|
||||||
|
|
||||||
|
#if BUILD_GUILE
|
||||||
|
#include "scm/mu-scm.hh"
|
||||||
|
#endif/*BUILD_GUILE*/
|
||||||
|
|
||||||
#include "utils/mu-error.hh"
|
#include "utils/mu-error.hh"
|
||||||
#include "utils/mu-utils-file.hh"
|
#include "utils/mu-utils-file.hh"
|
||||||
#include "utils/mu-utils.hh"
|
#include "utils/mu-utils.hh"
|
||||||
@ -43,7 +47,6 @@
|
|||||||
|
|
||||||
using namespace Mu;
|
using namespace Mu;
|
||||||
|
|
||||||
|
|
||||||
static Result<void>
|
static Result<void>
|
||||||
cmd_fields(const Options& opts)
|
cmd_fields(const Options& opts)
|
||||||
{
|
{
|
||||||
@ -63,6 +66,17 @@ cmd_find(const Options& opts)
|
|||||||
return mu_cmd_find(*store, opts);
|
return mu_cmd_find(*store, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Result<void>
|
||||||
|
cmd_scm(const Store& store, const Options& opts)
|
||||||
|
{
|
||||||
|
#if !BUILD_SCM
|
||||||
|
return Err(Error::Code::InvalidArgument,
|
||||||
|
"scm/guile is not available in this build");
|
||||||
|
#else
|
||||||
|
return Mu::Scm::run(Mu::Scm::Config{store, opts});
|
||||||
|
#endif /*BUILD_SCM*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
show_usage(void)
|
show_usage(void)
|
||||||
@ -133,6 +147,9 @@ Mu::mu_cmd_execute(const Options& opts) try {
|
|||||||
return cmd_find(opts);
|
return cmd_find(opts);
|
||||||
case Options::SubCommand::Info:
|
case Options::SubCommand::Info:
|
||||||
return with_readonly_store(mu_cmd_info, opts);
|
return with_readonly_store(mu_cmd_info, opts);
|
||||||
|
case Options::SubCommand::Scm:
|
||||||
|
return with_readonly_store(cmd_scm, opts);
|
||||||
|
|
||||||
|
|
||||||
/* writable store */
|
/* writable store */
|
||||||
|
|
||||||
|
|||||||
@ -545,7 +545,15 @@ sub_server(CLI::App& sub, Options& opts)
|
|||||||
sub.add_flag("--allow-temp-file", opts.server.allow_temp_file,
|
sub.add_flag("--allow-temp-file", opts.server.allow_temp_file,
|
||||||
"Allow for the temp-file optimization")
|
"Allow for the temp-file optimization")
|
||||||
->excludes("--commands");
|
->excludes("--commands");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sub_scm(CLI::App& sub, Options& opts)
|
||||||
|
{
|
||||||
|
sub.add_option("script-path", opts.scm.script_path, "Path to script")
|
||||||
|
->type_name("<path>");
|
||||||
|
sub.add_option("script-args", opts.scm.params, "Parameters for script")
|
||||||
|
->type_name("<parameters>");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -665,9 +673,13 @@ AssocPairs<SubCommand, CommandInfo, Options::SubCommandNum> SubCommandInfos= {{
|
|||||||
{Category::NeedsWritableStore,
|
{Category::NeedsWritableStore,
|
||||||
"remove", "Remove message from file-system and database", sub_remove }
|
"remove", "Remove message from file-system and database", sub_remove }
|
||||||
},
|
},
|
||||||
|
{ SubCommand::Scm,
|
||||||
|
{Category::None,
|
||||||
|
"scm", "Start Guile/Scheme shell",sub_scm}
|
||||||
|
},
|
||||||
{ SubCommand::Script,
|
{ SubCommand::Script,
|
||||||
// Note: SubCommand::Script is special; there's no literal
|
// Note: SubCommand::Script is special; there's no literal
|
||||||
// "script" subcommand, there subcommands for all the scripts.
|
// "script" subcommand, there are subcommands for all the scripts.
|
||||||
{Category::None,
|
{Category::None,
|
||||||
"script", "Invoke a script", {}}
|
"script", "Invoke a script", {}}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -40,6 +40,7 @@ struct Options {
|
|||||||
using SizeVec = std::vector<std::size_t>;
|
using SizeVec = std::vector<std::size_t>;
|
||||||
using OptTStamp = Option<std::time_t>;
|
using OptTStamp = Option<std::time_t>;
|
||||||
using OptFieldId = Option<Field::Id>;
|
using OptFieldId = Option<Field::Id>;
|
||||||
|
using OptString = Option<std::string>;
|
||||||
using StringVec = std::vector<std::string>;
|
using StringVec = std::vector<std::string>;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -62,7 +63,7 @@ struct Options {
|
|||||||
|
|
||||||
enum struct SubCommand {
|
enum struct SubCommand {
|
||||||
Add, Cfind, Extract, Fields, Find, Help, Index,Info, Init, Mkdir,
|
Add, Cfind, Extract, Fields, Find, Help, Index,Info, Init, Mkdir,
|
||||||
Move, Remove, Script, Server, Verify, View,
|
Move, Remove, Scm, Script, Server, Verify, View,
|
||||||
// <private>
|
// <private>
|
||||||
__count__
|
__count__
|
||||||
};
|
};
|
||||||
@ -80,6 +81,7 @@ struct Options {
|
|||||||
SubCommand::Mkdir,
|
SubCommand::Mkdir,
|
||||||
SubCommand::Move,
|
SubCommand::Move,
|
||||||
SubCommand::Remove,
|
SubCommand::Remove,
|
||||||
|
SubCommand::Scm,
|
||||||
SubCommand::Script,
|
SubCommand::Script,
|
||||||
SubCommand::Server,
|
SubCommand::Server,
|
||||||
SubCommand::Verify,
|
SubCommand::Verify,
|
||||||
@ -226,6 +228,16 @@ struct Options {
|
|||||||
StringVec files; /**< Files to remove */
|
StringVec files; /**< Files to remove */
|
||||||
} remove;
|
} remove;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Scm
|
||||||
|
*/
|
||||||
|
struct Scm {
|
||||||
|
OptString script_path; /**< Path to script (optional) */
|
||||||
|
StringVec params; /**< Parameters for script (after "--") */
|
||||||
|
} scm;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scripts (i.e., finding scriot)
|
* Scripts (i.e., finding scriot)
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user