}
//TODO LP: Add correct exitCodes
private QHostOptions parse(List<String> argList) throws Exception {
ResourceAttributeFilter resourceAttributeFilter = null;
ResourceFilter resourceFilter = null;
boolean showQueues = false;
boolean showJobs = false;
boolean showAsXML = false;
UserFilter userFilter = null;
HostFilter hostFilter = null;
while (!argList.isEmpty()) {
String arg = argList.remove(0);
if (arg.equals("-help")) {
out.println(getUsage());
return null;
} else if (arg.equals("-h")) {
if (argList.isEmpty()) {
err.println("error: ERROR! -h option must have argument");
return null;
}
arg = argList.remove(0);
//TODO LP: Qmaster should check if the value exists and is correct not the client
//E.g.: qhost -h dfds -> qmaster should try to resolve the host a return error message
hostFilter = HostFilter.parse(arg);
} else if (arg.equals("-F")) {
if (!argList.isEmpty()) {
arg = argList.get(0);
// we allow only a comma separated arg string
// qhost CLI allows also whitespace separated arguments
if (!arg.startsWith("-")) {
arg = argList.remove(0);
resourceAttributeFilter = ResourceAttributeFilter.parse(arg);
} else {
resourceAttributeFilter = new ResourceAttributeFilter();
}
} else {
resourceAttributeFilter = new ResourceAttributeFilter();
}
} else if (arg.equals("-j")) {
showJobs = true;
} else if (arg.equals("-l")) {
if (argList.isEmpty()) {
err.println("error: ERROR! -l option must have argument");
return null;
}
resourceFilter = new ResourceFilter();
arg = argList.remove(0);
try {
//TODO LP: Qmaster should check if the value exists and is correct not the client
//E.g.: qhost -l bal=34 -> qmaster should say bla does not exist
//E.g.: qhost -l swap_total -> qmaster - no value to swap_total