if (properties.containsKey("rank")) {
rank = Integer.parseInt((String) properties.get("rank"));
}
// Find or create the subshell group
GroupNode gn = layout;
String shell = (String) properties.get("shell");
String[] aliases = properties.get("alias") != null ? properties.get("alias").toString().split(",") : new String[0];
if (name.equals(shell))
{
Node n = gn.find(shell);
MutableGroupNode g = new MutableGroupNode(shell);
gn.add(g);
register(command);
}
else
{
if (shell != null && shell.length() > 0) {
Node n = gn.find(shell);
if (n == null) {
MutableGroupNode g = new MutableGroupNode(shell);
gn.add(g);
register(new GroupCommand(shell, g));
gn = g;
} else if (n instanceof GroupNode) {
gn = (GroupNode) n;
} else {
throw new IllegalStateException("A command conflicts has been detected when registering " + command.getId());
}
}
CommandNode cn = new CommandNode(name, command.getId());
gn.add(cn);
for (int i = 0; i < aliases.length; i++) {
if (!name.equals(aliases[i])) {
AliasNode an = new AliasNode(aliases[i], ALIAS_PREFIX + command.getId());
gn.add(an);
}
}
register(command);
}