}
public void execute() throws Exception {
PrintWriter out = getOutput().getPrintWriter();
PrintWriter err = getError().getPrintWriter();
SyntaxManager synMgr = ShellUtils.getCurrentSyntaxManager();
if (argDumpAll.isSet()) {
for (String alias : synMgr.getKeys()) {
SyntaxBundle bundle = synMgr.getSyntaxBundle(alias);
dumpSyntax(alias, bundle, out);
}
} else {
String alias;
if (argDump.isSet()) {
alias = getAlias();
SyntaxBundle bundle = synMgr.getSyntaxBundle(alias);
if (bundle == null) {
err.format(err_no_alias, alias);
} else {
dumpSyntax(alias, bundle, out);
}
} else if (argFile.isSet()) {
alias = getAlias();
File file = argFile.getValue();
XMLElement xml = new XMLElement();
FileReader reader = null;
try {
reader = new FileReader(file);
xml.parseFromReader(new BufferedReader(reader));
xml.setAttribute("alias", alias);
SyntaxBundle bundle =
new SyntaxSpecLoader().loadSyntax(new XMLSyntaxSpecAdapter(xml));
synMgr.add(bundle);
} catch (IOException ex) {
err.format(err_file_read, alias, ex.getLocalizedMessage());
} finally {
if (reader != null) {
reader.close();
}
}
} else if (argRemove.isSet()) {
alias = getAlias();
synMgr.remove(alias);
} else {
for (String key : synMgr.getKeys()) {
out.println(key);
}
}
}
}