use of com.evolveum.midpoint.cli.seppuku.action.Action in project midpoint by Evolveum.
the class Main method start.
private void start(String[] args) {
LOG.debug("Arguments: {}", Arrays.toString(args));
DefaultCommand def = new DefaultCommand();
JCommander commander = new JCommander(def);
for (Map.Entry<String, ActionValue> entry : ACTIONS.entrySet()) {
ActionValue value = entry.getValue();
commander.addCommand(entry.getKey(), value.command);
}
commander.parse(args);
String cmd = commander.getParsedCommand();
LOG.debug("Parsed command: '{}'", cmd);
if (StringUtils.isEmpty(cmd)) {
if (def.isVersion()) {
printVersion();
}
if (def.isHelp()) {
printHelp(commander);
}
return;
}
ActionValue actionValue = null;
for (Map.Entry<String, ActionValue> entry : ACTIONS.entrySet()) {
if (cmd != null && cmd.equals(entry.getKey())) {
actionValue = entry.getValue();
break;
}
}
if (actionValue == null) {
printHelp(commander);
return;
}
try {
LOG.debug("Executing action {} with params {}", actionValue.action.getSimpleName(), actionValue.command);
Action action = createAction(actionValue.action, actionValue.command, commander);
action.execute();
} catch (Exception ex) {
handleError(ex);
}
}
Aggregations