Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
winseros committed Mar 27, 2022
2 parents 8486048 + cba115b commit 68dcbda
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 18 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions doc/pbo_json.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ An example `pbo.json`:
"value": "my-mod"
}],
"compress": {
"include": ["\.txt$", "\.sqf$", "\.ext"],
"include": ["\\.txt$", "\\.sqf$", "\\.ext"],
"exclude": ["^description.ext$"]
}
}
Expand Down Expand Up @@ -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$` |
17 changes: 14 additions & 3 deletions pbom/commandline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -48,6 +49,10 @@ namespace pboman3 {
bool prompt() const {
return !!*optPrompt;
}

bool noUi() const {
return !!*optNoUi;
}
};

struct CommandPack : PackCommandBase {
Expand All @@ -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);

}
};

Expand All @@ -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);
}
};

Expand Down
45 changes: 38 additions & 7 deletions pbom/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion pbom/model/task/packtask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
13 changes: 11 additions & 2 deletions pbom/util/log.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "log.h"
#include <QLoggingCategory>

namespace pboman3::util {
LogWorker::LogWorker(QtMessageHandler implementation)
Expand Down Expand Up @@ -26,8 +27,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);
Expand All @@ -41,5 +41,14 @@ 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}");
#ifdef NDEBUG
QLoggingCategory::setFilterRules("*.debug=false");
#endif

}

LoggingInfrastructure* LoggingInfrastructure::logging_ = nullptr;
}
2 changes: 2 additions & 0 deletions pbom/util/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ namespace pboman3::util {
QThread thread_;
LogWorker* worker_;
};

void UseLoggingMessagePattern();
}

0 comments on commit 68dcbda

Please sign in to comment.