From af53a5c40ea4b950ba7a4e057d3742b6c25efa13 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Tue, 10 Mar 2009 21:20:06 +0100
Subject: [PATCH] Beautify the cluster status list

This patch removes the primary/secondary instance lists from the node
status and also removes the tabbed formatting with explicit width
formatting.
---
 src/Cluster.hs |  4 +++-
 src/Node.hs    | 10 ++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/Cluster.hs b/src/Cluster.hs
index 753b6e11c..e7deb2899 100644
--- a/src/Cluster.hs
+++ b/src/Cluster.hs
@@ -565,7 +565,9 @@ printNodes :: [(Int, String)] -> NodeList -> String
 printNodes ktn nl =
     let snl = sortBy (compare `on` Node.idx) (Container.elems nl)
         snl' = map (\ n -> ((fromJust $ lookup (Node.idx n) ktn), n)) snl
-    in unlines $ map (uncurry Node.list) snl'
+        m_name = maximum . (map length) . fst . unzip $ snl'
+        helper = Node.list m_name
+    in unlines $ map (uncurry helper) snl'
 
 -- | Compute the mem and disk covariance.
 compDetailedCV :: NodeList -> (Double, Double)
diff --git a/src/Node.hs b/src/Node.hs
index 0312ccfd4..2d128a40a 100644
--- a/src/Node.hs
+++ b/src/Node.hs
@@ -197,18 +197,16 @@ str t =
       (commaJoin (map show (slist t)))
 
 -- | String converter for the node list functionality.
-list :: String -> Node -> String
-list n t =
+list :: Int -> String -> Node -> String
+list mname n t =
     let pl = plist t
         sl = slist t
         mp = p_mem t
         dp = p_dsk t
         fn = failN1 t
     in
-      printf " %c %s(%d)\t%5d\t%5d\t%3d\t%3d\t%s\t%s\t%.5f\t%.5f"
+      printf " %c %-*s %5d %5d %3d %3d %.5f %.5f"
                  (if fn then '*' else ' ')
-                 n (idx t) (f_mem t) ((f_dsk t) `div` 1024)
+                 mname n (f_mem t) ((f_dsk t) `div` 1024)
                  (length pl) (length sl)
-                 (commaJoin (map show pl))
-                 (commaJoin (map show sl))
                  mp dp
-- 
GitLab