}
}
private static void runTool(CommandLine cmd, File f) throws InstantiationException, IllegalAccessException,
ClassNotFoundException, Exception, IOException {
LogFormat format;
if (cmd.hasOption("c")) {
format = (LogFormat) Class.forName(cmd.getOptionValue("c")).newInstance();
} else if (cmd.hasOption("x")) {
String configName = cmd.getOptionValue("x");
format = SavedLogFormatLoader.load(configName);
} else {
format = new PlainTextLogFormat();
}
WrappedCharBuffer buffer = WrappedCharBuffer.fromFile(f);
Less tool = new Less();
tool.createDefaultCommands();
tool.addCommand(new RendererCommand(tool, format));
tool.addCommand(new ModelsCommand(format, buffer, tool));
if (format.supportsEvents()) {
tool.addCommand(new SelectEventCommand(format, tool));
}
if (format.supportsRequests()) {
tool.addCommand(new SelectRequestCommand(format, tool));
}
tool.addCommand(new ScrollbarCommand(tool, buffer));
tool.setLineNumbers(BasicLineNumberIndex.create(buffer));