Change default output behavior a little bit
This commit is contained in:
parent
0ba3f6ca39
commit
634e14aeeb
@ -34,8 +34,8 @@ int main(int argc, char *argv[])
|
|||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription("The nymea plugin info compiler. Compiles a plugininfo.json into a plugininfo.h/plugininfo-extern.h.");
|
parser.setApplicationDescription("The nymea plugin info compiler. Compiles a plugininfo.json into a plugininfo.h/plugininfo-extern.h.");
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
parser.addOption({{"o", "output"}, "Write generated output header to <file>.", "file", "-"});
|
parser.addOption({{"o", "output"}, "Write generated output header to <file>.", "file"});
|
||||||
parser.addOption({{"e", "extern"}, "Write generated output header (extern definitions) to <file>.", "file", "-"});
|
parser.addOption({{"e", "extern"}, "Write generated output header (extern definitions) to <file>.", "file"});
|
||||||
parser.addPositionalArgument("input", "The input json file");
|
parser.addPositionalArgument("input", "The input json file");
|
||||||
|
|
||||||
parser.process(a);
|
parser.process(a);
|
||||||
|
|||||||
@ -60,6 +60,7 @@ int PluginInfoCompiler::compile(const QString &inputFile, const QString &outputF
|
|||||||
|
|
||||||
// OK. Json parsed fine. Let's open files for writing
|
// OK. Json parsed fine. Let's open files for writing
|
||||||
|
|
||||||
|
if (!outputFile.isEmpty()) {
|
||||||
if (outputFile == "-") {
|
if (outputFile == "-") {
|
||||||
if (!m_outputFile.open(stdout, QFile::WriteOnly | QFile::Text)) {
|
if (!m_outputFile.open(stdout, QFile::WriteOnly | QFile::Text)) {
|
||||||
qWarning() << "Error opening stdout for writing. Aborting.";
|
qWarning() << "Error opening stdout for writing. Aborting.";
|
||||||
@ -72,7 +73,9 @@ int PluginInfoCompiler::compile(const QString &inputFile, const QString &outputF
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!outputFileExtern.isEmpty()) {
|
||||||
if (outputFileExtern == "-") {
|
if (outputFileExtern == "-") {
|
||||||
if (!m_outputFileExtern.open(stdout, QFile::WriteOnly | QFile::Text)) {
|
if (!m_outputFileExtern.open(stdout, QFile::WriteOnly | QFile::Text)) {
|
||||||
qWarning() << "Error opening stdout for writing. Aborting.";
|
qWarning() << "Error opening stdout for writing. Aborting.";
|
||||||
@ -85,6 +88,7 @@ int PluginInfoCompiler::compile(const QString &inputFile, const QString &outputF
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Files are open. Ready to write content.
|
// Files are open. Ready to write content.
|
||||||
|
|
||||||
@ -278,10 +282,14 @@ void PluginInfoCompiler::writeActionTypes(const ActionTypes &actionTypes, const
|
|||||||
|
|
||||||
void PluginInfoCompiler::write(const QString &line)
|
void PluginInfoCompiler::write(const QString &line)
|
||||||
{
|
{
|
||||||
|
if (m_outputFile.isOpen()) {
|
||||||
m_outputFile.write(QString("%1\n").arg(line).toUtf8());
|
m_outputFile.write(QString("%1\n").arg(line).toUtf8());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PluginInfoCompiler::writeExtern(const QString &line)
|
void PluginInfoCompiler::writeExtern(const QString &line)
|
||||||
{
|
{
|
||||||
|
if (m_outputFileExtern.isOpen()) {
|
||||||
m_outputFileExtern.write(QString("%1\n").arg(line).toUtf8());
|
m_outputFileExtern.write(QString("%1\n").arg(line).toUtf8());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user