X-Git-Url: http://nitlanguage.org diff --git a/src/nitls.nit b/src/nitls.nit index a79454e..62fc09f 100644 --- a/src/nitls.nit +++ b/src/nitls.nit @@ -22,7 +22,7 @@ import ordered_tree import console class ProjTree - super OrderedTree[Object] + super OrderedTree[MConcern] var opt_paths = false var tc: ToolContext @@ -87,34 +87,16 @@ class ProjTree 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 - var tc = new ToolContext var opt_keep = new OptionBool("Ignore errors and files that are not a Nit source file", "-k", "--keep") -var opt_recursive = new OptionBool("Process directories recussively", "-r", "--recursive") +var opt_recursive = new OptionBool("Process directories recursively", "-r", "--recursive") var opt_tree = new OptionBool("List source files in their groups and packages", "-t", "--tree") -var opt_source = new OptionBool("List source files", "-s", "--source") -var opt_package = new OptionBool("List packages paths (default)", "-P", "--package") +var opt_source = new OptionBool("List source files in a flat list", "-s", "--source") +var opt_package = new OptionBool("List packages in a flat list (default)", "-P", "--package") var opt_depends = new OptionBool("List dependencies of given modules", "-d", "--depends") -var opt_make = new OptionBool("List dependencies suitable for a rule in a Makefile. Alias for -d, -p and -s", "-M") -var opt_paths = new OptionBool("List only path (instead of name + path)", "-p", "--path") +var opt_make = new OptionBool("List dependencies suitable for a rule in a Makefile (alias for -d, -p and -s)", "-M") +var opt_paths = new OptionBool("List only path (instead of name + path)", "-p", "--path-only") tc.option_context.add_option(opt_keep, opt_recursive, opt_tree, opt_source, opt_package, opt_depends, opt_paths, opt_make) tc.tooldescription = "Usage: nitls [OPTION]... ...\nLists the packages and/or paths of Nit sources files." @@ -189,7 +171,6 @@ if opt_depends.value then end var ot = new ProjTree(tc) -var sorter = new AlphaEntityComparator if opt_tree.value then ot.opt_paths = opt_paths.value var mgroups = new HashSet[MGroup] @@ -197,7 +178,10 @@ if opt_tree.value then var pa = mp.mgroup while pa != null and not pa.is_interesting do pa = pa.parent ot.add(pa, mp) - if pa != null then mgroups.add pa + while pa != null do + mgroups.add pa + pa = pa.parent + end end for g in mgroups do var pa = g.parent @@ -205,17 +189,19 @@ if opt_tree.value then ot.add(pa, g) end end - ot.sort_with(sorter) + ot.sort_with(alpha_comparator) ot.write_to(stdout) end if opt_source.value then - sorter.sort(mmodules) + alpha_comparator.sort(mmodules) for mp in mmodules do - if opt_paths.value then + if opt_make.value then + print mp.filepath.escape_to_mk + else if opt_paths.value then print mp.filepath.as(not null) else - print "{mp.mgroup.full_name}/{ot.display(mp)}" + print "{mp.mgroup.full_name}{ot.display(mp)}" end end end @@ -228,7 +214,7 @@ if opt_package.value then mpackages.add p end - sorter.sort(mpackages) + alpha_comparator.sort(mpackages) for p in mpackages do var g = p.root.as(not null) var path = g.filepath.as(not null)