+
+ # Build the nitweb config from `toolcontext` options.
+ fun build_config(toolcontext: ToolContext, mainmodule: MModule): NitwebConfig do
+
+ var model = toolcontext.modelbuilder.model
+
+ var filter = new ModelFilter(
+ if toolcontext.opt_no_private.value then protected_visibility else private_visibility,
+ accept_fictive = not toolcontext.opt_no_fictive.value,
+ accept_empty_doc = not toolcontext.opt_no_empty_doc.value,
+ accept_test = not toolcontext.opt_no_test.value,
+ accept_attribute = not toolcontext.opt_no_attribute.value
+ )
+
+ var catalog = build_catalog(toolcontext.modelbuilder, filter)
+
+ var config = new NitwebConfig(model, mainmodule, toolcontext.modelbuilder, filter, catalog)
+ var config_file = toolcontext.opt_config.value
+ if config_file == null then config.default_config_file = "nitweb.ini"
+ config.parse_options(args)
+ var opt_host = toolcontext.opt_host.value
+ if opt_host != null then config.ini["app.host"] = opt_host
+ var opt_port = toolcontext.opt_port.value
+ if opt_port >= 0 then config.ini["app.port"] = opt_port.to_s
+ return config
+ end
+