2017-02-15 08:50:11 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-02-15 08:50:11 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-02-15 08:50:11 +00:00
|
|
|
*/
|
|
|
|
#include "codegen/emoji/options.h"
|
|
|
|
|
|
|
|
#include <ostream>
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
#include "codegen/common/logging.h"
|
|
|
|
|
|
|
|
namespace codegen {
|
|
|
|
namespace emoji {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr int kErrorOutputPathExpected = 902;
|
2017-07-19 18:37:49 +00:00
|
|
|
constexpr int kErrorReplacesPathExpected = 903;
|
|
|
|
constexpr int kErrorOneReplacesPathExpected = 904;
|
2017-02-15 08:50:11 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
using common::logError;
|
|
|
|
|
|
|
|
Options parseOptions() {
|
|
|
|
Options result;
|
|
|
|
auto args = QCoreApplication::instance()->arguments();
|
|
|
|
for (int i = 1, count = args.size(); i < count; ++i) { // skip first
|
|
|
|
auto &arg = args.at(i);
|
|
|
|
|
|
|
|
// Output path
|
|
|
|
if (arg == "-o") {
|
|
|
|
if (++i == count) {
|
|
|
|
logError(kErrorOutputPathExpected, "Command Line") << "output path expected after -o";
|
|
|
|
return Options();
|
|
|
|
} else {
|
|
|
|
result.outputPath = args.at(i);
|
|
|
|
}
|
|
|
|
} else if (arg.startsWith("-o")) {
|
|
|
|
result.outputPath = arg.mid(2);
|
2017-04-03 18:49:07 +00:00
|
|
|
#ifdef SUPPORT_IMAGE_GENERATION
|
2017-03-31 19:08:25 +00:00
|
|
|
} else if (arg == "--images") {
|
|
|
|
result.writeImages = true;
|
2017-04-03 18:49:07 +00:00
|
|
|
#endif // SUPPORT_IMAGE_GENERATION
|
2017-07-19 18:37:49 +00:00
|
|
|
} else if (result.replacesPath.isEmpty()) {
|
|
|
|
result.replacesPath = arg;
|
|
|
|
} else {
|
|
|
|
logError(kErrorOneReplacesPathExpected, "Command Line") << "only one replaces path expected";
|
|
|
|
return Options();
|
2017-02-15 08:50:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (result.outputPath.isEmpty()) {
|
|
|
|
logError(kErrorOutputPathExpected, "Command Line") << "output path expected";
|
|
|
|
return Options();
|
2017-07-19 18:37:49 +00:00
|
|
|
} else if (result.replacesPath.isEmpty()) {
|
|
|
|
logError(kErrorReplacesPathExpected, "Command Line") << "replaces path expected";
|
|
|
|
return Options();
|
2017-02-15 08:50:11 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace emoji
|
|
|
|
} // namespace codegen
|