-# Nitx phase explores the model and prepares the console rendering.
-private class NitxPhase
- super Phase
- redef fun process_mainmodule(mainmodule, mmodules)
- do
- var doc = new DocModel(mainmodule.model, mainmodule)
-
- var phases = [
- new ExtractionPhase(toolcontext, doc),
- new MakePagePhase(toolcontext, doc),
- new ConcernsPhase(toolcontext, doc),
- new StructurePhase(toolcontext, doc): DocPhase]
-
- for phase in phases do
- toolcontext.info("# {phase.class_name}", 1)
- phase.apply
+# Nitx handles console queries
+#
+# Using `prompt`, the command line can be turned on an interactive tool.
+class Nitx
+
+ # Model that contains the informations to display
+ var model: Model
+
+ # Mainmodule for class linearization
+ var mainmodule: MModule
+
+ # ModelBuilder to access AST nodes
+ var modelbuilder: ModelBuilder
+
+ # Catalog if any
+ var catalog: nullable Catalog = null is optional
+
+ # Do not use colors in the output
+ var no_color = false is optional
+
+ # Displays the welcome message and start prompt.
+ fun start do
+ welcome
+ prompt
+ end
+
+ # Displays the welcome message and the list of loaded modules.
+ fun welcome do
+ print "Welcome in the Nit Index!"
+ print ""
+ print "Loaded packages:\n"
+ var cmd = new CmdModelEntities(model, kind = "packages")
+ cmd.init_command
+ for mpackage in cmd.results.as(not null) do
+ print " * {mpackage.full_name}"
+ end
+ help
+ end
+
+ # Displays the list of available queries.
+ fun help do
+ # TODO automatize that
+ print "\nCommands:\n"
+ for usage, doc in parser.commands_usage do
+ var l = usage.length / 8
+ print "\t{usage}{"\t" * (3 - l)}{doc}"