Get Output from Terminal Window IDE - intellij-idea

I am developing a plugin in Intellij to be used in Pycharm. One problem that I am currently facing is, how can I get the output from the IDE terminal after I execute some command. To execute a command I use the ShellTerminalWidget that creates a new tab in the IDE terminal and executes the command I want. But I need a way to read that output.
Thanks.
Command Execution

It seems consoleFilterProvider extension is what you need.
A simple plugin example with the feature can be found here:
https://github.com/siosio/consoleLink

Related

After building a Kotlin program in IntelliJ, how do I execute it directly from the terminal? [duplicate]

I have installed IntelliJ IDEA on my mac and wrote the simplest Kotlin program
fun main(args : Array<String>){
println("Hello")
}
I can run it from the IDE environment. (It prints Hello of course)
My question: How can you run this from the console?
What I have done:
I tried to call
java simplekt.class
but I got
Error: could not find or load main class simplekt.class
I tried java simplekt but then I got an exception in thread main java.lang.NoClassDefFoundError
I tried to use kotlin or kotlinc but the command was not found. (where is the compiler installed?)
In this resource they use kotlinc and they produce a jar file but IDEA only output a class file.
Not really sure how to proceed from here.
When you run your application from the IDE, in the Run window the very first line is the command that the IDE executes to start your program. In my case it's something like:
/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 <a lot more omitted>
You can execute the same command in your terminal and that will execute the application. Reading that line will also (indirectly) tell you where the kotlinc command is installed, and in my case – using MacOS – it's at /Applications/IntelliJ\ IDEA.app/Contents/plugins/Kotlin/kotlinc/bin/kotlinc
However, you can always decide to entirely stop using the IDE and compile/run your program from the command line by following instructions here: https://kotlinlang.org/docs/tutorials/command-line.html
The above answer by #user2340612 is mostly right, but maybe due to software changing or some differences in what i did, it did not work for me. Following did:
to avoid repetition, i'll be using the short name: $(ideac) = "IntelliJ IDEA Community Edition 2022.2" in place of the full name
the path to the kotlinc is this one: $(ideac)\plugins\Kotlin\kotlinc\bin
much similar to the one told above, but slightly different
i have verified it to work in the command given in the command-line doc linked above or compiler-reference too: kotlinc hello.kt -include-runtime -d hello.jar
running the resultant .jar file via java -jar ./hello.jar shows the expected output
there's no kotlin-native in that folder, so, couldn't verify this native-command-line-compiler kotlin doc
Backstory/What did not work
the command under the run tab in $(ideac) no longer shows the kotlinc path
I had created the Kotlin "project" by using "new project" (intelliJ) or by "Kotlin multiplatform > JVM" (gradle)
The run command for either of these did not contain any kotlinc in them
I tried creating a new > "scratch" file; and it showed this: $(ideac)\plugins\Kotlin\bin\windows\LLDBFrontend.exe but i tried using that on CLI and it did not work either

Cucumber-java test steps execute twice in IntelliJ

Normally I run Cucumber-Jvm tests using Run/Debug configuration. Once I tried to run one tests using Run window by selecting the scenario (right click and run)
From that point on wards I see each time when I run test using Edit Configuration I see steps run twice.
I am using IntelliJ Community version
Anyone had this issue before could be any settings change.
Right click on the Play button on your .feature file and select the last choice 'Create Scenario ...'. On the Program arguments box you should have CucumberJvm5SMFormatter only ONCE. I had:
--plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter --plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter --name "^My Scenario$"
Simply, I deleted the second line:
--plugin org.jetbrains.plugins.cucumber.java.run.CucumberJvm5SMFormatter --name "^My Scenario$"
and it ran perfectly!
Also depends on number of examples you have provided in cucumber
You have probably another test with the same name

Pipe console output of IntelliJ to a script

It is possible to pipe the console output of an intellij application to a bash command so I can pretty-print it on the console directly?
I know I can save the log output to a file, but I still want to keep it on the stout window only, but just parse it through a script.
Piping output is a feature of the terminal shell.
IntelliJ IDEA is not using a terminal to run your app, therefore it's not possible with the default Run/Debug configurations.
You could use an external tool that will open a command line shell and run your app there, but the shell has to be open in a separate window and it will not be possible to get the formatted output directly in the IDE.
There is a related feature request in YouTrack, but it's unlikely to be implemented soon.

Run IntelliJ code formatter from the command line

I am trying to run IntelliJ code formatter from command line.
I know that inspections can be run from CLI, however, they didn't provide the same for the source formatting (lame!).
Now, I started with CE edition of IntelliJ. Source code is on github.
However, since the code base is not small, I am having problems encapsulating the formatter.
Is there anyone who can point me in right direction and showing which classes to start with?
You can run the formatter from the terminal now. Like the code inspection.
https://confluence.jetbrains.com/display/IDEADEV/Command-Line+Source+Code+Formatter
/bin/format.sh [-h] [-r|-R] [-s|-settings settingsPath] [-m|-mask masks] [path1 [path2]...]
On Windows it's /bin/format.bat
To do this in the new versions of Intellij
You need to make sure the command line launcher is installed via the Jetbrain Toolbox.
Toolbox App Announcement
And run the following command from your shell:
idea format -s /path/to/your/style.xml /path/to/your/folder
I would recommend that you set the shell script location to /usr/local/bin/

Is it possible to launch more than one Webstorm instance using the command-line launcher?

Webstorm can be launched from the command line using the command wstorm. However, would it be possible to launch more than one instance? Usually, the second time I run wstorm, it doesn't open another Webstorm for me and does nothing.
In OS X, this is apparently caused by an outdated wstorm (a Python script at /usr/local/bin/wstorm). I verified the solution indicated in this ticket with WebStorm 2016.1.3:
Go to Tools > Create Command-line Launcher....
UPDATE Nov-2016: As of WebStorm 2016.3, the default name of the launcher changed from wstorm to webstorm. If you prefer wstorm instead, make sure to edit the script name before clicking OK:
Just run:
WebStorm.exe "Full\path\to\the\project\that\contains\the\.idea\folder\of\your\project"
The project will run in the same instance but in a separted window as described here: https://www.jetbrains.com/webstorm/help/opening-multiple-projects.html
NOTE: This was tested on WebStorm 9.0.3 and may not work on previous versions.