+import console
+
+class ProjTree
+ super OrderedTree[Object]
+
+ var opt_paths = false
+ var tc: ToolContext
+
+ redef fun display(o)
+ do
+ if o isa MGroup then
+ if opt_paths then
+ return o.filepath.as(not null)
+ else
+ var d = ""
+ if o.mdoc != null then
+ if tc.opt_no_color.value then
+ d = ": {o.mdoc.content.first}"
+ else
+ d = ": {o.mdoc.content.first.green}"
+ end
+ end
+ if tc.opt_no_color.value then
+ return "{o.name}{d} ({o.filepath.to_s})"
+ else
+ return "{o.name}{d} ({o.filepath.yellow})"
+ end
+ end
+ else if o isa ModulePath then
+ if opt_paths then
+ return o.filepath
+ else
+ var d = ""
+ var dd = ""
+ if o.mmodule != null and o.mmodule.mdoc != null then
+ if tc.opt_no_color.value then
+ d = ": {o.mmodule.mdoc.content.first}"
+ else
+ d = ": {o.mmodule.mdoc.content.first.green}"
+ end
+ end
+ if o.mmodule != null and not o.mmodule.in_importation.direct_greaters.is_empty then
+ var ms = new Array[String]
+ for m in o.mmodule.in_importation.direct_greaters do
+ if m.mgroup.mpackage == o.mmodule.mgroup.mpackage then
+ ms.add m.name
+ else
+ ms.add m.full_name
+ end
+ end
+ if tc.opt_no_color.value then
+ dd = " ({ms.join(" ")})"
+ else
+ dd = " ({ms.join(" ")})".light_gray
+ end
+ end
+ if tc.opt_no_color.value then
+ return "{o.name.bold}{d} ({o.filepath.to_s}){dd}"
+ else
+ return "{o.name.bold}{d} ({o.filepath.yellow}){dd}"
+ end
+ end
+ else
+ abort
+ end
+ end
+end
+
+class AlphaEntityComparator
+ super Comparator
+ fun nameof(a: COMPARED): String
+ do
+ if a isa MGroup then
+ return a.name
+ else if a isa ModulePath then
+ return a.name
+ else
+ abort
+ end
+ end
+ redef fun compare(a,b)
+ do
+ return nameof(a) <=> nameof(b)
+ end
+end