Browse Source

fix PlantUML command

Le Tan 6 years ago
parent
commit
39795c3daa
2 changed files with 25 additions and 1 deletions
  1. 23 1
      src/vplantumlhelper.cpp
  2. 2 0
      src/vplantumlhelper.h

+ 23 - 1
src/vplantumlhelper.cpp

@@ -46,7 +46,7 @@ void VPlantUMLHelper::processAsync(int p_id,
         QStringList args(m_args);
         args << ("-t" + p_format);
         qDebug() << m_program << args;
-        process->start(m_program, args);
+        process->start(m_program, refineArgsForUse(args));
     } else {
         QString cmd(m_customCmd);
         cmd.replace("%0", p_format);
@@ -143,6 +143,7 @@ bool VPlantUMLHelper::testPlantUMLJar(const QString &p_jar, QString &p_msg)
     VPlantUMLHelper inst(p_jar);
     QStringList args(inst.m_args);
     args << "-tsvg";
+    args = refineArgsForUse(args);
 
     QString testGraph("VNote->Markdown : hello");
 
@@ -175,6 +176,7 @@ QByteArray VPlantUMLHelper::process(const QString &p_format, const QString &p_te
     if (inst.m_customCmd.isEmpty()) {
         QStringList args(inst.m_args);
         args << ("-t" + p_format);
+        args = refineArgsForUse(args);
         ret = VProcessUtils::startProcess(inst.m_program,
                                           args,
                                           p_text.toUtf8(),
@@ -1109,3 +1111,23 @@ creole:
     tryCreole(kw);
     return kw;
 }
+
+QStringList VPlantUMLHelper::refineArgsForUse(const QStringList &p_args)
+{
+    if (p_args.isEmpty()) {
+        return QStringList();
+    }
+
+    if (p_args[0] == "-c") {
+        QStringList args;
+        args << p_args[0];
+        QString subCmd;
+        for (int i = 1; i < p_args.size(); ++i) {
+            subCmd += " " + p_args[i];
+        }
+        args << subCmd;
+        return args;
+    } else {
+        return p_args;
+    }
+}

+ 2 - 0
src/vplantumlhelper.h

@@ -41,6 +41,8 @@ private:
 
     void prepareCommand(QString &p_cmd, QStringList &p_args, const QString &p_jar= QString()) const;
 
+    static QStringList refineArgsForUse(const QStringList &p_args);
+
     QString m_program;
 
     QStringList m_args;