From 041a4c8e677e405ead0978999bb2534a6a480c11 Mon Sep 17 00:00:00 2001 From: Nikita Kobzev Date: Thu, 23 Dec 2021 20:04:22 +0300 Subject: [PATCH 1/3] Added the escaping backslashes into the docs --- doc/pbo_json.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/pbo_json.md b/doc/pbo_json.md index f949eed..884f242 100644 --- a/doc/pbo_json.md +++ b/doc/pbo_json.md @@ -17,7 +17,7 @@ An example `pbo.json`: "value": "my-mod" }], "compress": { - "include": ["\.txt$", "\.sqf$", "\.ext"], + "include": ["\\.txt$", "\\.sqf$", "\\.ext"], "exclude": ["^description.ext$"] } } @@ -82,7 +82,7 @@ There are lots of the services for regular expression debugging, such as https:/ | What it will match | Example files | RegEx | | ------------------------------------------------- | ------------------------------------------------------------------ | ---------------------- | -| All the `.sqf` files. | `my-script.sqf` or `Scripts/script.sqf` | `\.sqf$` | -| All the `.sqf` files in the `Scripts` root foler. | `Scripts/Client/Alpha/fn_run.sqf` | `^scripts\/.+\.sqf$` | -| All the `.sqf` files in the `Alpha` subfolders. | `Scripts/Client/Alpha/initClient.sqf` or `Scripts/Server/Alpha/initServer.sqf` | `\/.+\/Alpha\/.+\.sqf$` | +| All the `.sqf` files. | `my-script.sqf` or `Scripts/script.sqf` | `\\.sqf$` | +| All the `.sqf` files in the `Scripts` root foler. | `Scripts/Client/Alpha/fn_run.sqf` | `^scripts\/.+\\.sqf$` | +| All the `.sqf` files in the `Alpha` subfolders. | `Scripts/Client/Alpha/initClient.sqf` or `Scripts/Server/Alpha/initServer.sqf` | `\/.+\/Alpha\/.+\\.sqf$` | | The `decription.ext` file in the root. | `description.ext` | `^description.ext$` | From 5385141ae473f7a8a4938bbdc8a4eff575d1be47 Mon Sep 17 00:00:00 2001 From: winse Date: Mon, 21 Mar 2022 21:54:35 +0300 Subject: [PATCH 2/3] Add the --no-ui option to pack/unpack from scripts --- CHANGELOG.md | 7 +++++- pbom/commandline.h | 17 +++++++++++--- pbom/main.cpp | 45 ++++++++++++++++++++++++++++++------ pbom/model/task/packtask.cpp | 2 +- pbom/util/log.cpp | 9 ++++++-- pbom/util/log.h | 2 ++ 6 files changed, 68 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbfb469..1a1cba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ # PBO Manager change log -## Version 1.1.0 +## Version 1.3.0 + - [Feature] Added the `--no-ui` command line flag for usage in scripts + +## Version 1.2.0 + - [Feature] Support of PBO metadata provisioning through pbo.json or $PBOPREFIX$ files +## Version 1.1.0 - [Enhancement] UI no longer freezes when opening a PBO - [Enhancement] UI no longer freezes when pasting files into a PBO from the file system - [Enhancement] Progress operations are displayed in the Windows taskbar diff --git a/pbom/commandline.h b/pbom/commandline.h index f8846ff..6555f9e 100644 --- a/pbom/commandline.h +++ b/pbom/commandline.h @@ -34,12 +34,13 @@ namespace pboman3 { }; struct PackCommandBase : Command { - PackCommandBase() : optOutputPath(nullptr), optPrompt(nullptr) { + PackCommandBase() : optOutputPath(nullptr), optPrompt(nullptr), optNoUi(nullptr) { } string outputPath; Option* optOutputPath; Option* optPrompt; + Option* optNoUi; bool hasOutputPath() const { return !!*optOutputPath; @@ -48,6 +49,10 @@ namespace pboman3 { bool prompt() const { return !!*optPrompt; } + + bool noUi() const { + return !!*optNoUi; + } }; struct CommandPack : PackCommandBase { @@ -67,6 +72,10 @@ namespace pboman3 { optPrompt = command->add_flag("-p,--prompt", "Show a UI dialog for the output directory selection") ->excludes(optOutputPath); + + optNoUi = command->add_flag("-u,--no-ui", "Run the application without the GUI") + ->excludes(optPrompt); + } }; @@ -85,8 +94,10 @@ namespace pboman3 { ->check(ExistingDirectory); optPrompt = command->add_flag("-p,--prompt", - "Show a UI dialog for the output directory selection") - ->excludes(optOutputPath); + "Show a UI dialog for the output directory selection"); + + optNoUi = command->add_flag("-u,--no-ui", "Run the application without the GUI") + ->excludes(optPrompt); } }; diff --git a/pbom/main.cpp b/pbom/main.cpp index f23e074..f02950a 100644 --- a/pbom/main.cpp +++ b/pbom/main.cpp @@ -10,6 +10,8 @@ #include "ui/packwindow.h" #include "ui/unpackwindow.h" #include "exception.h" +#include "model/task/packtask.h" +#include "model/task/unpacktask.h" #include "util/log.h" #define LOG(...) LOGGER("Main", __VA_ARGS__) @@ -122,6 +124,26 @@ namespace pboman3 { return exitCode; } + int RunConsolePackOperation(const QStringList& folders, const QString& outputDir) { + util::UseLoggingMessagePattern(); + for (const QString& folder : folders) { + //don't parallelize to avoid mess in the console + model::task::PackTask task(folder, outputDir); + task.execute([] { return false; }); + } + return 0; + } + + int RunConsoleUnpackOperation(const QStringList& folders, const QString& outputDir) { + util::UseLoggingMessagePattern(); + for (const QString& folder : folders) { + //don't parallelize to avoid mess in the console + model::task::UnpackTask task(folder, outputDir); + task.execute([] { return false; }); + } + return 0; + } + int RunWithCliOptions(int argc, char* argv[]) { using namespace CLI; using namespace pboman3; @@ -141,8 +163,6 @@ namespace pboman3 { const QString file = CommandLine::toQt(commandLine->open.fileName); exitCode = RunMainWindow(app, file); } else if (commandLine->pack.hasBeenSet()) { - const PboApplication app(argc, argv); - QString outputDir; if (commandLine->pack.hasOutputPath()) outputDir = CommandLine::toQt(commandLine->pack.outputPath); @@ -152,10 +172,14 @@ namespace pboman3 { outputDir = QDir::currentPath(); const QStringList folders = CommandLine::toQt(commandLine->pack.folders); - exitCode = RunPackWindow(app, folders, outputDir); + if (commandLine->pack.noUi()) { + exitCode = RunConsolePackOperation(folders, outputDir); + } + else { + const PboApplication app(argc, argv); + exitCode = RunPackWindow(app, folders, outputDir); + } } else if (commandLine->unpack.hasBeenSet()) { - const PboApplication app(argc, argv); - QString outputDir; if (commandLine->unpack.hasOutputPath()) outputDir = CommandLine::toQt(commandLine->unpack.outputPath); @@ -165,7 +189,12 @@ namespace pboman3 { outputDir = QDir::currentPath(); const QStringList files = CommandLine::toQt(commandLine->unpack.files); - exitCode = RunUnpackWindow(app, files, outputDir); + if (commandLine->unpack.noUi()) { + exitCode = RunConsoleUnpackOperation(files, outputDir); + } else { + const PboApplication app(argc, argv); + exitCode = RunUnpackWindow(app, files, outputDir); + } } else { //should not normally get here; if did - CLI11 was misconfigured somewhere cout << cli.help(); @@ -203,6 +232,8 @@ int main(int argc, char* argv[]) { try { const int res = pboman3::RunMain(argc, argv); return res; - } catch (...) { + } catch (const pboman3::AppException& ex) { + LOG(critical, "Unexpected exception has been thrown:", ex); + throw ex; } } diff --git a/pbom/model/task/packtask.cpp b/pbom/model/task/packtask.cpp index b1391f1..829d2f1 100644 --- a/pbom/model/task/packtask.cpp +++ b/pbom/model/task/packtask.cpp @@ -95,7 +95,7 @@ namespace pboman3::model::task { try { writer.write(&document, cancel); - LOG(info, "Unpack complete") + LOG(info, "Pack complete") } catch (const DiskAccessException& ex) { LOG(warning, "Task failed with exception:", ex) emit taskMessage("Failure | " + ex.message() + " | " + folder.absolutePath()); diff --git a/pbom/util/log.cpp b/pbom/util/log.cpp index 795be09..7ea4026 100644 --- a/pbom/util/log.cpp +++ b/pbom/util/log.cpp @@ -26,8 +26,7 @@ namespace pboman3::util { } void LoggingInfrastructure::run() { - qSetMessagePattern( - "%{time yyyy-MM-dd HH:mm:ss.zzz}|%{if-debug}DBG%{endif}%{if-info}INF%{endif}%{if-warning}WRN%{endif}%{if-critical}CRT%{endif}%{if-fatal}FTL%{endif}|%{file}|%{message}"); + UseLoggingMessagePattern(); worker_ = new LogWorker(qInstallMessageHandler(handleMessage)); worker_->moveToThread(&thread_); thread_.start(QThread::LowPriority); @@ -41,5 +40,11 @@ namespace pboman3::util { emit logging_->messageReceived(type, context.file, message); } + void UseLoggingMessagePattern() { + qSetMessagePattern( + "%{time yyyy-MM-dd HH:mm:ss.zzz}|%{if-debug}DBG%{endif}%{if-info}INF%{endif}%{if-warning}WRN%{endif}%{if-critical}CRT%{endif}%{if-fatal}FTL%{endif}|%{file}|%{message}"); + + } + LoggingInfrastructure* LoggingInfrastructure::logging_ = nullptr; } diff --git a/pbom/util/log.h b/pbom/util/log.h index dfbbfe8..06868d1 100644 --- a/pbom/util/log.h +++ b/pbom/util/log.h @@ -69,4 +69,6 @@ namespace pboman3::util { QThread thread_; LogWorker* worker_; }; + + void UseLoggingMessagePattern(); } From cba115b00c706dce7a40c5216af5892542ce7aa3 Mon Sep 17 00:00:00 2001 From: winse Date: Sat, 26 Mar 2022 21:55:13 +0300 Subject: [PATCH 3/3] Disabled the console log flood in console in the release mode by-default --- pbom/util/log.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pbom/util/log.cpp b/pbom/util/log.cpp index 7ea4026..96f5b63 100644 --- a/pbom/util/log.cpp +++ b/pbom/util/log.cpp @@ -1,4 +1,5 @@ #include "log.h" +#include namespace pboman3::util { LogWorker::LogWorker(QtMessageHandler implementation) @@ -43,6 +44,9 @@ namespace pboman3::util { void UseLoggingMessagePattern() { qSetMessagePattern( "%{time yyyy-MM-dd HH:mm:ss.zzz}|%{if-debug}DBG%{endif}%{if-info}INF%{endif}%{if-warning}WRN%{endif}%{if-critical}CRT%{endif}%{if-fatal}FTL%{endif}|%{file}|%{message}"); +#ifdef NDEBUG + QLoggingCategory::setFilterRules("*.debug=false"); +#endif }