Revision 9fb621af src/Ganeti/Common.hs
b/src/Ganeti/Common.hs | ||
---|---|---|
7 | 7 |
|
8 | 8 |
{- |
9 | 9 |
|
10 |
Copyright (C) 2009, 2010, 2011, 2012 Google Inc. |
|
10 |
Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
|
|
11 | 11 |
|
12 | 12 |
This program is free software; you can redistribute it and/or modify |
13 | 13 |
it under the terms of the GNU General Public License as published by |
... | ... | |
62 | 62 |
|
63 | 63 |
import Ganeti.BasicTypes |
64 | 64 |
import qualified Ganeti.Constants as C |
65 |
import Ganeti.Utils (wrap) |
|
65 | 66 |
import qualified Ganeti.Version as Version (version) |
66 | 67 |
|
67 | 68 |
-- | Parameter type. |
... | ... | |
203 | 204 |
-- | Formats the description of various commands. |
204 | 205 |
formatCommands :: (StandardOptions a) => PersonalityList a -> [String] |
205 | 206 |
formatCommands personalities = |
206 |
-- FIXME: add wrapping of descriptions
|
|
207 |
map (\(cmd, (_, _, _, desc)) -> printf " %-*s - %s" mlen cmd desc::String) $
|
|
207 |
concatMap (\(cmd, (_, _, _, desc)) ->
|
|
208 |
fmtDesc cmd (wrap maxWidth desc) "-" []) $
|
|
208 | 209 |
sortBy (comparing fst) personalities |
209 | 210 |
where mlen = min maxCmdLen . maximum $ map (length . fst) personalities |
211 |
maxWidth = 79 - 3 - mlen |
|
212 |
fmtDesc _ [] _ acc = reverse acc |
|
213 |
fmtDesc cmd (d : ds) sep acc = |
|
214 |
fmtDesc "" ds " " (printf " %-*s %s %s" mlen cmd sep d : acc) |
|
210 | 215 |
|
211 | 216 |
-- | Formats usage for a multi-personality program. |
212 | 217 |
formatCmdUsage :: (StandardOptions a) => String -> PersonalityList a -> String |
Also available in: Unified diff