0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-20 11:53:46 +02:00

cosntruct: Add multi-command -execute support.

This commit is contained in:
Jason Volk 2020-04-24 16:42:15 -07:00
parent a2f55eeab8
commit 94ff1fbafe
3 changed files with 5 additions and 14 deletions

View file

@ -81,14 +81,6 @@ construct::console::spawn()
return true;
}
bool
construct::console::execute(std::string cmd)
{
console::queue.emplace_back(std::move(cmd));
console::spawn();
return true;
}
bool
construct::console::interrupt()
{

View file

@ -46,6 +46,5 @@ struct construct::console
static bool active();
static bool interrupt();
static bool terminate();
static bool execute(std::string cmd);
static bool spawn();
};

View file

@ -38,7 +38,7 @@ bool write_avoid;
bool soft_assert;
bool nomatrix;
bool matrix {true}; // matrix server by default.
const char *execute;
std::vector<std::string> execute;
std::array<bool, 7> smoketest;
lgetopt opts[]
@ -49,7 +49,7 @@ lgetopt opts[]
{ "quiet", &quietmode, lgetopt::BOOL, "Suppress log messages at the terminal." },
{ "single", &single, lgetopt::BOOL, "Single user mode for maintenance and diagnostic." },
{ "console", &cmdline, lgetopt::BOOL, "Drop to a command line immediately after startup" },
{ "execute", &execute, lgetopt::STRING, "Execute command lines immediately after startup" },
{ "execute", &execute, lgetopt::STRINGS, "Execute command lines immediately after startup" },
{ "nolisten", &nolisten, lgetopt::BOOL, "Normal execution but without listening sockets" },
{ "noautomod", &noautomod, lgetopt::BOOL, "Normal execution but without autoloading modules" },
{ "checkdb", &checkdb, lgetopt::BOOL, "Perform complete checks of databases when opening" },
@ -301,13 +301,13 @@ noexcept try
// If the user wants to immediately drop to an interactive command line
// without having to send a ctrl-c for it, that is provided here. This does
// not actually take effect until it's processed in the ios.run() below.
if(cmdline)
if(cmdline || !execute.empty())
construct::console::spawn();
// If the user wants to immediately process console commands
// non-interactively from a program argument input, that is enqueued here.
if(execute)
construct::console::execute({execute});
for(auto &&cmd : execute)
construct::console::queue.emplace_back(std::move(cmd));
// For developer debugging and testing this branch from a "-norun" argument
// will exit before committing to the ios.run().