File indexing completed on 2024-04-14 05:41:03

0001 /**
0002  * SPDX-FileCopyrightText: 2021 Sebastian Engel <kde@sebastianengel.eu>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "weaver.h"
0008 
0009 #include <config.h>
0010 
0011 #include <KAboutData>
0012 #include <KLocalizedString>
0013 
0014 int main(int argc, char **argv)
0015 {
0016     QCoreApplication app(argc, argv);
0017 
0018     KAboutData aboutData(QStringLiteral("basketweaver"), i18n("basketweaver"), VERSION);
0019     aboutData.setShortDescription(i18n("Encodes and decodes .baskets files"));
0020 
0021     KAboutData::setApplicationData(aboutData);
0022 
0023     QCommandLineParser parser;
0024     parser.addVersionOption();
0025     parser.addHelpOption();
0026 
0027     QCommandLineOption output(QStringList() << QStringLiteral("o") << QStringLiteral("output"),
0028                               i18n("Destination directory. Optional."),
0029                               QStringLiteral("directory"));
0030     parser.addOption(output);
0031 
0032     QCommandLineOption previewImg(QStringList() << QStringLiteral("p") << QStringLiteral("preview"),
0033                                   i18n("Use the <image> as preview image for a .baskets file. Must be a .png file."),
0034                                   QStringLiteral("image"));
0035     parser.addOption(previewImg);
0036 
0037     QCommandLineOption mode_unweave(QStringList()
0038                                         << QStringLiteral("u") << QStringLiteral("unweave") << QStringLiteral("x"),
0039                                     i18n("Decodes the <file>. Cannot be used together with --weave."),
0040                                     QStringLiteral("file"));
0041     parser.addOption(mode_unweave);
0042 
0043     QCommandLineOption mode_weave(QStringList()
0044                                       << QStringLiteral("w") << QStringLiteral("weave") << QStringLiteral("c"),
0045                                   i18n("Encodes the <directory>. Cannot be used together with --unweave."),
0046                                   QStringLiteral("directory"));
0047     parser.addOption(mode_weave);
0048 
0049     QCommandLineOption basename(
0050         QStringList() << QStringLiteral("n") << QStringLiteral("name"),
0051         i18n("This optional value will be used to label the new content within the optionally given output directory"),
0052         QStringLiteral("fileName"));
0053     parser.addOption(basename);
0054 
0055     QCommandLineOption forceOption(QStringList() << QStringLiteral("f") << QStringLiteral("force"),
0056                                    i18n("Overwrite existing files."));
0057     parser.addOption(forceOption);
0058 
0059     parser.process(app);
0060 
0061     Weaver weaver(&parser, mode_weave, mode_unweave, output, basename, previewImg, forceOption);
0062 
0063     return weaver.runMain();
0064 }