use of com.martiansoftware.nailgun.Alias in project nailgun by facebook.
the class NGAlias method nailMain.
public static void nailMain(NGContext context) throws ClassNotFoundException {
String[] args = context.getArgs();
NGServer server = context.getNGServer();
if (args.length == 0) {
Set aliases = server.getAliasManager().getAliases();
// let's pad this nicely. first, find the longest alias
// name. then pad the others to that width.
int maxAliasLength = 0;
int maxClassnameLength = 0;
for (Iterator i = aliases.iterator(); i.hasNext(); ) {
Alias alias = (Alias) i.next();
maxAliasLength = Math.max(maxAliasLength, alias.getName().length());
maxClassnameLength = Math.max(maxClassnameLength, alias.getAliasedClass().getName().length());
}
for (Iterator i = aliases.iterator(); i.hasNext(); ) {
Alias alias = (Alias) i.next();
context.out.println(padl(alias.getName(), maxAliasLength) + "\t" + padl(alias.getAliasedClass().getName(), maxClassnameLength));
context.out.println(padl("", maxAliasLength) + "\t" + alias.getDescription());
context.out.println();
}
} else if (args.length == 2) {
server.getAliasManager().addAlias(new Alias(args[0], "", Class.forName(args[1])));
}
}