From be5726ab7b5b48ea7b29a50aaf54189ebe1ff282 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 20 Aug 2017 02:33:22 +0200 Subject: Help: Right-align command names To aid the readability of the help output, align the dashes vertically so the descriptions are in a uniform place. The resulting output now looks like this: – Generate a commit URL based on the given SHA. git remote set origin URL – Set the git remote URL for this channel. help – Show a list of available bot commands. --- src/Plugin/Help.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Plugin/Help.hs b/src/Plugin/Help.hs index 470dd33..a141745 100644 --- a/src/Plugin/Help.hs +++ b/src/Plugin/Help.hs @@ -19,7 +19,12 @@ help = Plugin helpAction :: PluginAction helpAction _ = do return $ Right $ T.intercalate "\n" - [command p `T.append` " – " `T.append` description p | p <- plugins] + [T.justifyRight longestCommandLen ' ' (command p) + `T.append` " – " + `T.append` description p + | p <- plugins] + where + longestCommandLen = foldr (max) 0 (map (T.length . command) plugins) plugins :: [Plugin] plugins = PL.plugins ++ [help] -- cgit v1.2.3