commit 2a371bb4b3235462ea6632d31d50ee447933bef8 Author: Enrico Forestieri <for...@lyx.org> Date: Wed Aug 17 22:32:14 2016 +0200
Add verbose option Using the option -v (--verbose) all spawned commands are print on the terminal. Note that this was done by default on previous versions. --- lyx.1in | 3 +++ src/LyX.cpp | 17 +++++++++++++++++ src/LyX.h | 1 + src/client/client.cpp | 3 +++ src/frontends/qt4/GuiProgressView.cpp | 4 ++++ src/support/Systemcall.cpp | 6 +++++- src/support/filetools.cpp | 6 ++++++ src/tex2lyx/dummy_impl.cpp | 7 +++++++ 8 files changed, 46 insertions(+), 1 deletions(-) diff --git a/lyx.1in b/lyx.1in index 8f81660..ed1be04 100644 --- a/lyx.1in +++ b/lyx.1in @@ -94,6 +94,9 @@ by using the lyxpipe, ask an already running instance of LyX to open the documents passed as arguments and then exit. If the lyxpipe is not set up or is not working, a new instance is created and execution continues normally. .TP +\fB \-v [\-\-verbose]\fP +print on terminal all spawned external commands. +.TP .BI \-batch causes LyX to run the given commands without opening a GUI window. Thus, something like: diff --git a/src/LyX.cpp b/src/LyX.cpp index a732c7e..fec8281 100644 --- a/src/LyX.cpp +++ b/src/LyX.cpp @@ -92,6 +92,12 @@ namespace os = support::os; bool use_gui = true; +// Report on the terminal about spawned commands. The default is false +// and can be changed with the option -v (--verbose). + +bool verbose = false; + + // We default to open documents in an already running instance, provided that // the lyxpipe has been setup. This can be overridden either on the command // line or through preference settings. @@ -1161,6 +1167,8 @@ int parse_help(string const &, string const &, string &) "\t-r [--remote]\n" " open documents in an already running instance\n" " (a working lyxpipe is needed)\n" + "\t-v [--verbose]\n" + " report on terminal about spawned commands.\n" "\t-batch execute commands without launching GUI and exit.\n" "\t-version summarize version and build info\n" "Check the LyX man page for more details.")) << endl; @@ -1295,6 +1303,13 @@ int parse_remote(string const &, string const &, string &) } +int parse_verbose(string const &, string const &, string &) +{ + verbose = true; + return 0; +} + + int parse_force(string const & arg, string const &, string &) { if (arg == "all") { @@ -1342,6 +1357,8 @@ void LyX::easyParse(int & argc, char * argv[]) cmdmap["--no-remote"] = parse_noremote; cmdmap["-r"] = parse_remote; cmdmap["--remote"] = parse_remote; + cmdmap["-v"] = parse_verbose; + cmdmap["--verbose"] = parse_verbose; for (int i = 1; i < argc; ++i) { map<string, cmd_helper>::const_iterator it diff --git a/src/LyX.h b/src/LyX.h index a19b523..4b9c201 100644 --- a/src/LyX.h +++ b/src/LyX.h @@ -51,6 +51,7 @@ enum OverwriteFiles { }; extern bool use_gui; +extern bool verbose; extern RunMode run_mode; extern OverwriteFiles force_overwrite; diff --git a/src/client/client.cpp b/src/client/client.cpp index a950f83..023e73e 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -66,6 +66,9 @@ using namespace lyx::support; namespace lyx { +// Dummy verbose support +bool verbose = false; + // Dummy LyXRC support struct LyXRC { string icon_set; diff --git a/src/frontends/qt4/GuiProgressView.cpp b/src/frontends/qt4/GuiProgressView.cpp index 3a8f075..166eed7 100644 --- a/src/frontends/qt4/GuiProgressView.cpp +++ b/src/frontends/qt4/GuiProgressView.cpp @@ -195,6 +195,10 @@ void GuiProgressView::clearText() void GuiProgressView::appendLyXErrText(QString const & text) { + // Skip verbose messages meant for the terminal + if (text.startsWith("\nRunning:")) + return; + widget_->outTE->moveCursor(QTextCursor::End); widget_->outTE->insertPlainText(text); widget_->outTE->ensureCursorVisible(); diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index 5dd4a94..cc2c381 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -23,6 +23,7 @@ #include "support/os.h" #include "support/ProgressInterface.h" +#include "LyX.h" #include "LyXRC.h" #include <cstdlib> @@ -239,7 +240,10 @@ int Systemcall::startscript(Starttype how, string const & what, bool process_events) { string const what_ss = commandPrep(what); - LYXERR(Debug::INFO,"Running: " << what_ss); + if (verbose) + lyxerr << "\nRunning: " << what_ss << endl; + else + LYXERR(Debug::INFO,"Running: " << what_ss); string infile; string outfile; diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index b28d812..fcb95fa 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -21,6 +21,7 @@ #include <config.h> +#include "LyX.h" #include "LyXRC.h" #include "support/filetools.h" @@ -995,6 +996,11 @@ cmd_ret const runCommand(string const & cmd) // pstream (process stream), with the // variants ipstream, opstream + if (verbose) + lyxerr << "\nRunning: " << cmd << endl; + else + LYXERR(Debug::INFO,"Running: " << cmd); + #if defined (_WIN32) STARTUPINFO startup; PROCESS_INFORMATION process; diff --git a/src/tex2lyx/dummy_impl.cpp b/src/tex2lyx/dummy_impl.cpp index 7709663..8ad5b79 100644 --- a/src/tex2lyx/dummy_impl.cpp +++ b/src/tex2lyx/dummy_impl.cpp @@ -48,6 +48,13 @@ namespace Alert { // +// Dummy verbose support +// + +bool verbose = false; + + +// // Dummy LyXRC support //