File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -313,13 +313,16 @@ commandTree :: Parser a -> Doc
313313commandTree = vsep . commands
314314 where
315315 commands :: Parser x -> [Doc ]
316- commands = concat . mapParser (const entries)
317- entries :: Option x -> [Doc ]
316+ commands p = (\ (n, b) -> fill w (pretty n) <+> b) <$> cs
317+ where
318+ cs = concat (mapParser (const entries) p)
319+ w = maximum (0 : fmap (length . fst ) cs)
320+ entries :: Option x -> [(String , Doc )]
318321 entries o = case optMain o of
319- CmdReader _ cs -> uncurry entry <$> cs
322+ CmdReader _ cs -> fmap body <$> cs
320323 _ -> []
321- entry :: String -> ParserInfo x -> Doc
322- entry n i =
323- fill 12 (pretty n) <+> align (fromMaybe mempty (unChunk (infoProgDesc i))) <> case commands (infoParser i) of
324+ body :: ParserInfo x -> Doc
325+ body i =
326+ align (fromMaybe mempty (unChunk (infoProgDesc i))) <> case commands (infoParser i) of
324327 [] -> mempty
325328 sub -> line <> indent 2 (vsep sub) <> line
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ main = hspec $ do
137137 subparser (leaf " a" )
138138 <|> subparser (hidden <> command " b" (info (subparser (leaf " c" )) (progDesc " b desc" )))
139139 in show (commandTree p)
140- `shouldBe` " a a desc\n b b desc\n c c desc"
140+ `shouldBe` " a a desc\n b b desc\n c c desc\n "
141141
142142 describe " config keys" $ do
143143 it " parses TOML literals, falling back to strings" $
You can’t perform that action at this time.
0 commit comments