Answer the question
In order to leave comments, you need to log in
How in JetBrains idea plugin to execute on the command line with an argument consisting of several lines?
Good time. I am writing my own linter for a custom language. Linter is written in JS, and the IDE plugin communicates with it via the command line.
At first, I sent only the path of the file to the linter, but then it turned out that the IDE does not save the file right away, and what was in the editor did not always correspond to what was in the file.
I decided to send the contents of the file to the linter at the time of editing from the editor.
More or less like this
import com.intellij.execution.configurations.GeneralCommandLine;
...
GeneralCommandLine commandLine = new GeneralCommandLine();
commandLine.withCharset(StandardCharsets.UTF_8)
.setWorkDirectory(cwd);
commandLine.setExePath(StylusLinterExe);
commandLine.addParameter(file);
if (StringUtils.isNotEmpty(content)) {
commandLine.addParameter("--content");
commandLine.addParameter(content);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question