How to make IntelliJ prompt me for command line arguments

╄→гoц情女王★ 提交于 2020-01-20 03:50:26

问题


In Eclipse, you can provide the program argument ${string_prompt} in your run configuration to have it prompt for the command line arguments.

Is there a way to do this in IntelliJ?


回答1:


Edit:

This may be a bug in IDEA, the solution that I first posted (you can see it below) causes Intellij to hang after entering parameter.

I couldn't come up with a solution to this, but here's a little trick: you can scroll to the very bottom of Run/Debug configuration screen and in "Before launch" section check a checkbox saying "Show this page".

From now on you'll be automatically shown configuration screen when you choose to Run/Debug your application and there you can enter any parameters you want... It's not that comfortable, but at least a little bit more automatized.

Previous answer:

This is a bit more complicated with Intellij:

  • go to Settings -> External Tools -> Add (green plus)
  • in Parameters line click Insert macro -> Prompt (you can simply type in $Prompt$ as well)
  • save settings
  • go to Run -> Edit Configurations...
  • in Before Launch section choose Run External Tool and select tool that you've created

That should suffice (works in IDEA 12.1.6).




回答2:


Starting from versions 2018.3 and 2019.1, IntelliJ now supports macros in Run configurations. You can use $Prompt$ anywhere in the VM Options, Program arguments, etc. fields, and it will behave just like ${string_prompt} in Eclipse -- it will prompt you for parameters when the configuration is run.



来源:https://stackoverflow.com/questions/20689273/how-to-make-intellij-prompt-me-for-command-line-arguments

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!