I have two enums, one for apps and one for environments. I want to be able to give the arguments for these in any order, so I can give either -app app1 app1 -env env1 env2 or -env env1 env2 -app app1 app2. Right now I can only do the first one. I would also like to be able to just say -app app1 app2 and it runs all the apps I list in all environments and the same for the environments but I'm more concerned about being able to give them in either order.
for(int i = 0; i<args.length; i++)
{
if(args[i].equals("-app"))
{
indexOfApp = i;
}else if(args[i].equals("-env"))
{
indexOfEnv = i;
}
}
int countOfApp = -1;
int countOfEnv = -1;
if(indexOfApp != -1 && indexOfEnv != -1)
{
countOfApp = indexOfEnv - 1;
countOfEnv = args.length - (indexOfEnv + 1);
}
System.out.println(countOfApp);
System.out.println(countOfEnv);
for(int appIndex = indexOfApp + 1; appIndex < countOfApp + 1; appIndex++){
appList.add(args[appIndex]);
}
for(String item : appList )
{
Application app = Application.valueOf(Application.class, item);
appList2.add(app);
}
for(int envIndex = indexOfEnv + 1; envIndex < args.length; envIndex++){
envList.add(args[envIndex]);
}
for(String item : envList )
{
Environment env = Environment.valueOf(Environment.class, item);
envList2.add(env);
}
} System.out.println(appList); System.out.println(envList);
Application.chooseAppTest(appList2, envList2);