From 34e7c029bb21b7999def89cb59e8eff42f805294 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Sun, 4 Mar 2018 15:48:29 -0500 Subject: [PATCH] nitpm: list packages in alphabetical order MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- src/nitpm.nit | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/nitpm.nit b/src/nitpm.nit index 526c875..d61db8f 100644 --- a/src/nitpm.nit +++ b/src/nitpm.nit @@ -295,17 +295,30 @@ class CommandList redef fun apply(args) do var files = nitpm_lib_dir.files + var name_to_desc = new Map[String, nullable String] + var max_name_len = 0 + + # Collect package info for file in files do var ini_path = nitpm_lib_dir / file / "package.ini" if verbose then print "- Reading ini file at {ini_path}" var ini = new ConfigTree(ini_path) var tags = ini["package.tags"] - if tags != null then - print "{file.justify(15, 0.0)} {tags}" - else - print file - end + name_to_desc[file] = tags + max_name_len = max_name_len.max(file.length) + end + + # Sort in alphabetical order + var sorted_names = name_to_desc.keys.to_a + alpha_comparator.sort sorted_names + + # Print with clear columns + for name in sorted_names do + var col0 = name.justify(max_name_len+1, 0.0) + var col1 = name_to_desc[name] or else "" + var line = col0 + col1 + print line.trim end end end -- 1.7.9.5