9

Prompting the user in the Eclipse external tool run configuration is simple enough:

${string_prompt:"Enter a string":"DefaultString"}

However, is there a way for me to configure my run configuration to use this as two separate arguments to my external tool? Something that would result in:

my.exe --arg1=${string_prompt1} --arg2=${string_prompt1}

I definitely don't want to push this logic into the application, itself. I just want to simplify a local test build configuration. Any ideas?

kevinmm
  • 3,136
  • 4
  • 21
  • 24

2 Answers2

5

You can have only one prompt in which you can pass as many arguments as you want separated by spaces. The strings you provide with the prompt will be assigned to args variable of public static void main method of your class.

To provide defaults for more than a argument, you could use something like this:

${string_prompt:"Enter two values separated by space":firstDefault secondDefault}

If you need to repeat your test many times with same parameters, you can think about using a saved run configuration in which you fix your parameters (just list them into "Program arguments" of "Arguments" tab).

giampaolo
  • 6,906
  • 5
  • 45
  • 73
  • I understand the workaround that you are providing, but for a complex build, it is hard to remember all of the parameter names. This doesn't really meet the requirements of what I am asking for, but I am assuming that this feature simply does not exist in Eclipse's run configurations. – kevinmm Jan 07 '13 at 05:41
  • Just accepting this, since you were kind enough to provide the only reasonable workaround. – kevinmm Jan 07 '13 at 05:43
  • If you need a list of questions asked to user, consider as no-eclipse-feature workaround to code them in your main method or, if you do not want to touch your main method, you could also consider to have another java program that asks questions and do an operating system call to your starting class: http://stackoverflow.com/questions/5934341/how-to-call-external-executable-file-from-java?rq=1. – giampaolo Jan 07 '13 at 06:09
  • Of course are not eclipse based possibilities and are useless if you you are only interested in eclipse features. – giampaolo Jan 07 '13 at 06:11
4

You can use multiple string_prompt entries in your run configuration. This is what I'm currently using for a user/password combo in my Program arguments.

${string_prompt:Username:DefaultUsername} ${string_prompt:Password}

The first string_prompt shows a dialog box saying "Please input a value for Username", with the default value of DefaultUsername filled in. The second reads "Please input a value for Password" with no default value. Both arguments get passed in each time I run. Works great!

DevOhrion
  • 318
  • 1
  • 8