construct: Add -silent option to also suppress console result output.

This commit is contained in:
Jason Volk 2023-02-02 18:32:32 -08:00
parent 5ed2e64b62
commit 14b9c51a06
3 changed files with 16 additions and 3 deletions

View File

@ -84,6 +84,9 @@ construct::console::quit_when_done;
decltype(construct::console::interactive_when_done)
construct::console::interactive_when_done;
decltype(construct::console::silent)
construct::console::silent;
bool
construct::console::spawn()
{
@ -359,7 +362,12 @@ construct::console::handle_line_bymodule()
pbase(), pptr()
};
setp(pbase(), epptr());
record_append(str);
if(silent)
return 0;
std::cout << str;
wrote += size(str);
if(wrote >= size_t(ratelimit_bytes))
@ -369,7 +377,6 @@ construct::console::handle_line_bymodule()
wrote = 0;
}
setp(pbase(), epptr());
return 0;
}
@ -412,7 +419,7 @@ construct::console::handle_line_bymodule()
view(out, outbuf)
};
if(!endswith(str, '\n'))
if(!endswith(str, '\n') && !silent)
std::cout << std::endl;
return ret;

View File

@ -22,6 +22,7 @@ struct construct::console
static std::deque<std::string> queue;
static bool quit_when_done;
static bool interactive_when_done;
static bool silent;
std::string line;
std::string record_path;

View File

@ -49,6 +49,7 @@ bool defaults;
const char *bootstrap;
const char *diagnostic;
bool nobanner;
bool silentmode;
lgetopt opts[]
{
@ -85,6 +86,7 @@ lgetopt opts[]
{ "bootstrap", &bootstrap, lgetopt::STRING, "Bootstrap fresh database from event vector" },
{ "diagnostic", &diagnostic, lgetopt::STRING, "Specify a diagnostic type in conjunction with other commands" },
{ "nobanner", &nobanner, lgetopt::BOOL, "Terminal log enabled only in runlevel RUN" },
{ "silent", &silentmode, lgetopt::BOOL, "Like quiet mode without console output either" },
{ nullptr, nullptr, lgetopt::STRING, nullptr },
};
@ -629,8 +631,11 @@ applyargs()
if(soft_assert)
ircd::soft_assert.set("true");
if(quietmode || nobanner)
if(quietmode || nobanner || silentmode)
ircd::log::console_disable();
if(silentmode)
construct::console::silent = true;
}
///////////////////////////////////////////////////////////////////////////////