Add --offline flag.

This commit is contained in:
2025-04-09 23:23:22 +02:00
parent 3f821a6f31
commit e2742d5633
3 changed files with 18 additions and 3 deletions
+11 -2
View File
@@ -128,7 +128,7 @@ bool Processor::run()
void Processor::runDownloadQueue()
{
if (m_downloadJobs.isEmpty()) {
if (m_offline || m_downloadJobs.isEmpty()) {
QCoreApplication::quit();
return;
}
@@ -139,7 +139,6 @@ void Processor::runDownloadQueue()
void Processor::parseBCMR(const QString &path)
{
logFatal() << "doing it" << path;
QFile in(path);
if (in.open(QIODevice::ReadOnly)) {
char signature[4];
@@ -239,6 +238,16 @@ void Processor::parseBCHTx(QFile &file)
logFatal() << "parse tx is a TODO";
}
bool Processor::offline() const
{
return m_offline;
}
void Processor::setOffline(bool newOffline)
{
m_offline = newOffline;
}
Processor::MetaCategory *Processor::fetchOrCreate(const QString &catId)
{
auto iter = m_categories.find(catId);
+4 -1
View File
@@ -16,9 +16,11 @@ class Processor : QObject
Q_OBJECT
public:
Processor(const QString &inDir, const QString &outDir);
bool run();
bool offline() const;
void setOffline(bool newOffline);
private slots:
void runDownloadQueue();
@@ -50,6 +52,7 @@ private:
QNetworkAccessManager m_network;
QList<DownloadJob*> m_downloadJobs;
bool m_offline = false;
};
#endif
+3
View File
@@ -20,6 +20,8 @@ int main(int x, char **y) {
parser.addOption(verbose);
QCommandLineOption quiet(QStringList() << "quiet" << "q", "Be quiet, only errors are shown");
parser.addOption(quiet);
QCommandLineOption offline(QStringList() << "offline", "Don't download anything");
parser.addOption(offline);
parser.process(app.arguments());
auto args = parser.positionalArguments();
@@ -44,6 +46,7 @@ int main(int x, char **y) {
logger->addConsoleChannel();
Processor processor(args.at(0), args.at(1));
processor.setOffline(parser.isSet(offline));
if (!processor.run())
return 1;