2017-04-27 18:27:59 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-06-16 13:58:22 +00:00
|
|
|
/* Dirk Hohndel, 2015 */
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QCommandLineParser>
|
2017-02-05 20:44:11 +00:00
|
|
|
#include <QApplication>
|
2015-06-16 13:58:22 +00:00
|
|
|
#include <QDebug>
|
|
|
|
|
2017-02-05 20:44:11 +00:00
|
|
|
#include "core/qt-gui.h"
|
|
|
|
#include "core/qthelper.h"
|
2019-03-03 21:29:40 +00:00
|
|
|
#include "core/file.h"
|
2020-10-17 10:32:22 +00:00
|
|
|
#include "core/device.h"
|
2019-03-03 21:29:40 +00:00
|
|
|
#include "core/divesite.h"
|
2019-05-31 14:09:14 +00:00
|
|
|
#include "core/trip.h"
|
2017-02-05 20:44:11 +00:00
|
|
|
#include "core/save-html.h"
|
|
|
|
#include <stdio.h>
|
2015-06-16 13:58:22 +00:00
|
|
|
#include "git2.h"
|
2017-02-05 20:44:11 +00:00
|
|
|
#include "core/subsurfacestartup.h"
|
|
|
|
#include "core/divelogexportlogic.h"
|
|
|
|
#include "core/statistics.h"
|
2015-06-16 13:58:22 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2015-06-17 13:27:33 +00:00
|
|
|
QApplication *application = new QApplication(argc, argv);
|
2015-06-16 13:58:22 +00:00
|
|
|
git_libgit2_init();
|
2015-10-06 09:15:38 +00:00
|
|
|
copy_prefs(&default_prefs, &prefs);
|
2015-06-16 13:58:22 +00:00
|
|
|
init_qt_late();
|
|
|
|
|
|
|
|
QCommandLineParser parser;
|
|
|
|
QCommandLineOption sourceDirectoryOption(QStringList() << "s" << "source",
|
|
|
|
"Read git repository from <directory>",
|
|
|
|
"directory");
|
|
|
|
parser.addOption(sourceDirectoryOption);
|
|
|
|
QCommandLineOption outputDirectoryOption(QStringList() << "u" << "output",
|
|
|
|
"Write HTML files into <directory>",
|
|
|
|
"directory");
|
|
|
|
parser.addOption(outputDirectoryOption);
|
|
|
|
|
|
|
|
parser.process(*application);
|
|
|
|
|
|
|
|
QString source = parser.value(sourceDirectoryOption);
|
|
|
|
QString output = parser.value(outputDirectoryOption);
|
|
|
|
|
|
|
|
if (source.isEmpty() || output.isEmpty()) {
|
|
|
|
qDebug() << "need --source and --output";
|
|
|
|
exit(1);
|
|
|
|
}
|
2020-10-17 10:32:22 +00:00
|
|
|
int ret = parse_file(qPrintable(source), &dive_table, &trip_table, &dive_site_table, &device_table, &filter_preset_table);
|
2015-06-18 19:22:14 +00:00
|
|
|
if (ret) {
|
2015-06-17 13:27:33 +00:00
|
|
|
fprintf(stderr, "parse_file returned %d\n", ret);
|
2015-06-18 19:22:14 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2015-06-17 13:27:33 +00:00
|
|
|
|
|
|
|
// this should have set up the informational preferences - let's grab
|
|
|
|
// the units from there
|
2017-02-05 20:44:11 +00:00
|
|
|
prefs.unit_system = git_prefs.unit_system;
|
|
|
|
prefs.units = git_prefs.units;
|
2015-06-17 13:27:33 +00:00
|
|
|
|
|
|
|
// now set up the export settings to create the HTML export
|
2015-06-16 13:58:22 +00:00
|
|
|
struct htmlExportSetting hes;
|
|
|
|
hes.themeFile = "sand.css";
|
|
|
|
hes.exportPhotos = true;
|
|
|
|
hes.selectedOnly = false;
|
|
|
|
hes.listOnly = false;
|
|
|
|
hes.yearlyStatistics = true;
|
2015-06-18 19:23:30 +00:00
|
|
|
hes.subsurfaceNumbers = true;
|
2015-06-17 13:27:33 +00:00
|
|
|
exportHtmlInitLogic(output, hes);
|
2015-06-16 13:58:22 +00:00
|
|
|
exit(0);
|
|
|
|
}
|