public static void main(String[] args) throws Exception { Arguments arguments = parseCommandLine(args); if (arguments != null) { FitNesseContext context = loadContext(arguments); PageVersionPruner.daysTillVersionsExpire = arguments.getDaysTillVersionsExpire(); FitNesse fitnesse = new FitNesse(context); if (!arguments.isOmittingUpdates()) fitnesse.applyUpdates(); boolean started = fitnesse.start(); if (started) printStartMessage(arguments, context); } else { printUsage(); System.exit(1); } }
private static void printStartMessage(Arguments args, FitNesseContext context) { System.out.println("FitNesse (" + VERSION + ") Started..."); System.out.print(context.toString()); System.out.println( "\tpage version expiration set to " + args.getDaysTillVersionsExpire() + " days."); System.out.print(extraOutput); }
private static FitNesseContext loadContext(Arguments arguments) throws Exception { FitNesseContext context = new FitNesseContext(); ComponentFactory componentFactory = new ComponentFactory(context.rootPath); context.port = arguments.getPort(); context.rootPath = arguments.getRootPath(); context.rootPageName = arguments.getRootDirectory(); context.rootPagePath = context.rootPath + "/" + context.rootPageName; context.root = componentFactory.getRootPage( FileSystemPage.makeRoot(context.rootPath, context.rootPageName)); context.responderFactory = new ResponderFactory(context.rootPagePath); context.logger = makeLogger(arguments); context.authenticator = makeAuthenticator(arguments.getUserpass(), componentFactory); context.htmlPageFactory = componentFactory.getHtmlPageFactory(new HtmlPageFactory()); extraOutput = componentFactory.loadResponderPlugins(context.responderFactory); extraOutput += componentFactory.loadWikiWidgetPlugins(); extraOutput += componentFactory.loadWikiWidgetInterceptors(); extraOutput += componentFactory.loadContentFilter(); WikiImportTestEventListener.register(); return context; }
public static Arguments parseCommandLine(String[] args) { CommandLine commandLine = new CommandLine("[-p port][-d dir][-r root][-l logDir][-e days][-o][-a userpass]"); Arguments arguments = null; if (commandLine.parse(args)) { arguments = new Arguments(); if (commandLine.hasOption("p")) arguments.setPort(commandLine.getOptionArgument("p", "port")); if (commandLine.hasOption("d")) arguments.setRootPath(commandLine.getOptionArgument("d", "dir")); if (commandLine.hasOption("r")) arguments.setRootDirectory(commandLine.getOptionArgument("r", "root")); if (commandLine.hasOption("l")) arguments.setLogDirectory(commandLine.getOptionArgument("l", "logDir")); if (commandLine.hasOption("e")) arguments.setDaysTillVersionsExpire(commandLine.getOptionArgument("e", "days")); if (commandLine.hasOption("a")) arguments.setUserpass(commandLine.getOptionArgument("a", "userpass")); arguments.setOmitUpdates(commandLine.hasOption("o")); } return arguments; }
private static Logger makeLogger(Arguments arguments) { String logDirectory = arguments.getLogDirectory(); return logDirectory != null ? new Logger(logDirectory) : null; }