File indexing completed on 2024-12-22 04:48:18

0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2024 Louis Schul <schul9louis@gmail.com>
0003 
0004 #include "pumlHelper.h"
0005 
0006 #include "../cliHelper.h"
0007 
0008 bool PumlHelper::makeDiagram(const QString &inputStr, const QString diagName, const bool darkTheme)
0009 {
0010     const bool pumlExist = CLIHelper::commandExists(QStringLiteral("plantuml"));
0011     if (pumlExist) {
0012         const QString darkModeStr = darkTheme ? QStringLiteral(" -darkmode") : QLatin1String();
0013         const QString cmd = QStringLiteral("echo \"") + inputStr + QStringLiteral("\" | plantuml") + darkModeStr + QStringLiteral(" -pipe > ") + diagName;
0014         const QString pumlError = CLIHelper::execCommand(cmd);
0015         if (!pumlError.isEmpty()) {
0016             return false;
0017         }
0018     }
0019     return true;
0020 }